Hello everyone!
I need some help to identify the best way to get a template's "filename" related to a static page "pageid".
The problem began when I started adding/deleting static pages, the Ids broke their relations with filenames, probably because MySQL has an autonumber giving the Ids and not resetting them to zero...
So, instead of having a direct relation (pageid=1 => page_001.html, pageid=2 => page_002.html) I have ended with non-related pairs (pageid=5 => page_001.html), making it difficult to identify the correct "filename" for a given "pageid".
This can be done iterating through the "$pages_menu" array, searching for the correct key and get out the filename when found - the following piece of code is working good, but I would like some opinions on how to improve it or if there is a better way.
Code:
{assign var="pagefile" value=""}
{section name=pages loop=$pages_menu}
{if $pages_menu[pages].pageid eq $smarty.get.pageid}
{assign var="pagefile" value="`$pages_menu[pages].filename`"}
{/if}
{/section}
{* Now $pagefile has the correct filename *}
Thank you!
Raul Carvalho