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 (Moderator: Donald Lobo) »
  • Follows up on a late night discussion
Pages: [1]

Author Topic: Follows up on a late night discussion  (Read 1094 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Follows up on a late night discussion
July 01, 2009, 07:37:31 am
Hi,

quick reminder: the goal is to be able to insert extra content in any template, eg. the list of relationships in the main contact view form, the email and phone number of the contact in the participant detail templates.

To make it easy it should be done within the template, and add civicrm plugins to smarty.  I played with it and that's simple enough to add new functions in smarty.

What I imagined was (stupid example, list all the contacts in the group 42:

{civicrm_api var=$contacts command="contact/search" group=42 return=array("sort_name","email",...)}

This would fetch the list of contacts and assign it to contacts, that you can then loop normally

{foreach $contacts...}
<a href="mailto:{$contact.email}">{contact.sort_name}</a>

The only difference is that instead of having to do the fetch from within the php, you can do it from within the template.

beside {civicrm_api}, I thought about {civicrm_snippet uri="/..."} That would embed the html as generated in a snipped (eg the tag tab, the relationship tab...)

What do you think ? That's very much open right now. I've just done it for fetching datas from another application on mepwatch,  it works, so I'm guessing it's doable as well for datas from civicrm.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Follows up on a late night discussion
July 01, 2009, 11:32:49 am

hey xavier:

nice to meet u finally :) thanx for the belgian beer, we enjoyed it :)

all the smarty plugins are in: CRM/Core/Smarty/plugins/function*

writing something to call an api function and return the result as json/xml should be quite easy and a quick extension and can mimic the other functions in there

the other one is a bit harder: civicrm_snippet. While coding it is not a big deal, if we do it as a function call there is a possibility that some template variables can be overwritten and cause unexpected behavior. So we can experiment with it

wanna contribute a plugin function for both?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Follows up on a late night discussion
July 01, 2009, 10:54:58 pm
For the api call, I don't want to return as xml/json, but assign the results to smarty variables.

as for civicrm_snippet, I see the problem, but what if it's included at the bottom of the template ? it will override variables from the main one, but that aren't used anymore, are they ?

Anyway, yes, deserves a big warning, both because of that, and because you can easily add quite a few sql queries in the page.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Follows up on a late night discussion
July 02, 2009, 05:35:38 am
Quote from: xavier on July 01, 2009, 10:54:58 pm
For the api call, I don't want to return as xml/json, but assign the results to smarty variables.

i think smarty takes care of assigning to a variable. You'll need to read up on that in the smarty manual

Quote from: xavier on July 01, 2009, 10:54:58 pm
as for civicrm_snippet, I see the problem, but what if it's included at the bottom of the template ? it will override variables from the main one, but that aren't used anymore, are they ?

bottom of template should be fine

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Implemented
July 11, 2009, 02:58:39 am
Have a look there for more explanations
http://civicrm.org/node/599

http://issues.civicrm.org/jira/browse/CRM-4733
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Follows up on a late night discussion

This forum was archived on 2017-11-26.