OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Explanation of Syntax?

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

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.

Explanation of Syntax?

Postby mark » Tue Sep 30, 2008 6:25 pm

Could someone give me hand with some code here. An explanation of the code syntax is needed.
Here's the context of the code from: issue.tpl

Code: Select all
 {if $hasAccess}
                {foreach from=$article->getGalleys() item=galley name=galleyList}
                        <a href="{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$galley->getGa\
lleyId()}" class="file">{$galley->getLabel()|escape}</a>
                {/foreach}
                {/if}


Specifically, I'm studying .....
Code: Select all
{url page="article" op="view" path=$article->getBestArticleId($currentJournal)|to_array:$galley->getGa\
lleyId()}


I know url is a customize function in TemplateManager, as is to_array. I know what $article and $gallery are too.
I've learned that to_array is basically a call to func_get_args (I read up on this, but I'm not sure how it functions in a smarty template file)

but I can't figure out

Code: Select all
path=$article->getBestArticleId($currentJournal)|to_array:$galley->getGalleyId()


What do the "|" and ":" do? Is that Smarty syntax or PHP syntax? It's very hard to search for their meaning because most search engines seem to ignore "|" and ":" as search terms.

Overall, I'm working on code that wants to emulate what the above code does with a slight twist. But I can't seem to make it work in the same way.

:(
mark
 
Posts: 31
Joined: Fri Jul 11, 2008 10:57 am

Re: Explanation of Syntax?

Postby jmacgreg » Wed Oct 01, 2008 10:34 am

Hi Mark,

Actually, this is a good excuse for me to dig a little deeper into Smarty syntax. I came up with the following explanation from http://www.smarty.net/manual/en/language.modifiers.php:

Variable modifiers can be applied to variables, custom functions or strings. To apply a modifier, specify the value followed by a | (pipe) and the modifier name. A modifier may accept additional parameters that affect its behavior. These parameters follow the modifer name and are separated by a : (colon). Also, all php-functions can be used as modifiers implicitly (more below) and modifiers can be combined.


There are a number of examples on the above page.

Cheers,
James
jmacgreg
 
Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest