OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Adding PHP function to Smarty template "record.tpl"

Open Harvester Systems support questions and answers, bug reports, and development issues.

Moderators: jmacgreg, michael, John

Forum rules
Developer Resources:

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome.

Adding PHP function to Smarty template "record.tpl"

Postby mobleyt » Thu Jan 13, 2011 2:47 pm

I am currently attempting to implement some PHP to link thumbnail images for each record item when records are listed in our archives.

I intend to use portions of the records' oai urls, which are available through the "getIdentifier" function from the record.inc.php file in "classes/record/".

I see that in "templates/browse/record.tpl" I can add elements to the template's "iterate" function for listing records. However, since the templates are constructed with Smarty's syntax, I'm having trouble writing this function in a way that Smarty will accept. Is it possible to include a php script into the tpl file? I'm just not familiar with Smarty, so I'm not sure how to code this in the proper syntax.

I hope this makes sense!
mobleyt
 
Posts: 7
Joined: Thu Jan 13, 2011 10:10 am

Re: Adding PHP function to Smarty template "record.tpl"

Postby asmecher » Tue Jan 18, 2011 8:32 pm

Hi mobleyt,

Smarty is quite easy to use for simple tasks -- if you're doing anything more than {foreach ...} or {if ...} statements, consider doing the heavy lifting in PHP (e.g. in plugins/schemas/dc/DublinCorePlugin.inc.php, by overriding the parent class's displayRecord function) and then using Smarty to simply display the results. You can embed PHP directly in Smarty using {php} ... {/php} blocks, but I wouldn't recommend doing it that way.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8449
Joined: Wed Aug 10, 2005 12:56 pm


Return to Open Harvester Systems Support and Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron