CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • improving hook_civicrm_links output
Pages: [1]

Author Topic: improving hook_civicrm_links output  (Read 861 times)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
improving hook_civicrm_links output
June 23, 2010, 03:30:05 pm
Currently the links created by this hook are displayed well enough to work properly, which is great, but I'd like to request that we have them displayed in similar fashion to the other links around them.  This is not possible now because of the way they're output to the browser.

Whereas other links across the top of the Contact Summary are each presented in an <li> element of <ul id="actions">, these links are actually inserted as simple <a> links all within the same <li> as the activities drop-down list.

To change this, I would like to move the processing for {$hookLinks} out of templates/CRM/Activity/Form/ActivityLinks.tpl and into /templates/CRM/Contact/Page/View/Summary.tpl, where they can be processed as individual <li> elements each containing a single <a> element.

(BTW, I have also submitted a patch providing support for 'id' attributes on these links, but this seems like it's different enough to warrant a little more discussion.)

Any reaction from the CiviCRM core team?

Thanks,
Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: improving hook_civicrm_links output
June 25, 2010, 05:55:40 am
IMO html related stuff should be kept in template file. ( for eg: <li> )

Kurund
Found this reply helpful? Support CiviCRM

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: improving hook_civicrm_links output
June 25, 2010, 08:13:37 am
HI Kurund,

Oh, sure.  Actually, I'm only suggesting changing the template itself, not inserting HTML into the structure of the hook's return value.  The hook's return value data structure can remain unchanged.

Here's some sample template output to illustrate.  Right now the hook's return value is passed to the template as $hookLinks, which the template processes by inserting them into the same <li> as the actions <select> element, like so (this code is created by templates/CRM/Activity/Form/ActivityLinks.tpl) :

Code: [Select]
<ul id="actions">
    <li> <!-- EDIT link is here -->  </li>
   
    <li> <!-- DELETE link is here --> </li>
   
    <li>
        <select class="form-select" id="other_activity" name="other_activity" onchange="...">  <!-- options --> </select>
        <!-- here's where the hook links are inserted -->
        <a href="hook/path/foo">Foo</a>
        <a href="hook/path/bar">Bar</a>
        <a href="hook/path/baz">Baz</a>
    </li>
   
    <li> <span class="label">Go to:</span> </li>
    <li> <!-- DASHBOARD link is here --> </li>

I'm suggesting that we use the template to render those hook links as <li><a>x</a></li>, like so:

Code: [Select]
<ul id="actions">
    <li> <!-- EDIT link is here --> </li>
   
    <li> <!-- DELETE link is here --> </li>
   
    <li>
        <select class="form-select" id="other_activity" name="other_activity" onchange="..."> <!-- options --> </select>
    </li>
   
    <!-- here's where the hook links are inserted -->
    <li> <a href="hook/path/foo">Foo</a> </li>
    <li> <a href="hook/path/bar">Bar</a> </li>
    <li> <a href="hook/path/baz">Baz</a> </li>   
   
    <li> <span class="label">Go to:</span> </li>
    <li> <!-- DASHBOARD link is here --> </li>
</ul>

To make this change, we would need to take the {$hookLinks} processing out of templates/CRM/Activity/Form/ActivityLinks.tpl and put it in templates/CRM/Contact/Page/View/Summary.tpl

I'm attaching a small patch to show more clearly what I'm suggesting.

What do you think?

- A.
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: improving hook_civicrm_links output
June 25, 2010, 09:27:10 am
Have you seen CiviCRM 3.2 ?
Check new actions: http://sandbox.civicrm.org/civicrm/contact/view?reset=1&cid=102

Kurund
Found this reply helpful? Support CiviCRM

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: improving hook_civicrm_links output
June 25, 2010, 09:36:38 am
Looks like 3.2 will change the context of this discussion.  Will have to play with that and bring this up again if necessary.

Thanks.

- A.
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • improving hook_civicrm_links output

This forum was archived on 2017-11-26.