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
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 7
Joined: Thu Jan 13, 2011 10:10 am

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 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!

Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

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/, 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.

Alec Smecher
Public Knowledge Project Team

Return to “Open Harvester Systems Support and Development”

Who is online

Users browsing this forum: No registered users and 2 guests