Page 1 of 1

smarty question regarding $urllinks

Posted: Wed Apr 23, 2008 1:59 pm
by struba
Hi!

I have a question regarding Smarty. There is a custom php script running on my server. I didn't write that but I'm trying to figure out how it works so i can implement another function. The person who made it used Smarty template engine and I can not quite figure out what happens.

This is the first part of the script, the comment on the first line says: load links from news feeds

// laad de links van de news feeds
$urllinks = array();
foreach($params['items'] as $item) {
 $url = $item->link;
 $title = strtolower($item->title);
 // strip trailing "/somenumber" part
 $url = ereg_replace("(/news/[0-9]*)/(.*)","\\1/", $url);
 $urllinks[$title] = trim($url);
}

It makes an array of all the stuff in $urlinks but where can I figure out how $urllinks is made up?

Thanks in advance!
Struba

Re: smarty question regarding $urllinks

Posted: Wed Apr 23, 2008 3:18 pm
by thoms
As far as I can see, your question has nothing to do with CMS made simple, right?
So you're a little bit at the wrong place in this forum.

Further, your question has also nothing to do with smarty, but only plain PHP.

Some hints:

The funktrion creates an associative array called "$urllinks" and fills it with the data from another array called "params".
Thereby the key of the array is the string "$title" and the value seems to be an $url.

See the PHP manual:
http://de.php.net/manual/en/language.types.array.php

I have to say that I don't really understand your problem. $urllink is "made up" exactly before your eyes.

Thomas

Re: smarty question regarding $urllinks

Posted: Wed Apr 23, 2008 5:33 pm
by Vin
So... if I understand it correctly, you're trying to find out how the output of $urllinks is sent to Smarty templates.

If so, try looking for smarty_assign function in the code.

There is a documentation for Smarty, too - http://www.smarty.net/

Re: smarty question regarding $urllinks

Posted: Thu Apr 24, 2008 11:18 am
by struba
thoms wrote:
I have to say that I don't really understand your problem. $urllink is "made up" exactly before your eyes.
yeah you are right :-[. i figured that out in the mean time. I'm going to check out the code in my index file now and see what gives.

Thanks,
Struba