X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Get template filename from pageid (https://forum.x-cart.com/showthread.php?t=12757)

raulcarvalho 03-11-2005 01:59 PM

Get template filename from pageid
 
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

shan 03-14-2005 03:25 AM

wouldnt it be better to give your pages a more descriptive name in the first place ?

raulcarvalho 03-14-2005 05:42 AM

Descriptive names
 
Hello Shan!

Quote:

Originally Posted by shan
wouldnt it be better to give your pages a more descriptive name in the first place ?


Do you mean "betterpagename.html" instead of "page_001.html"?

This is not the issue, since having more descriptive names still don't help me find the filename from the pageid...

Anyway, the described method above works but I feel it should be simpler...

Thanks!


All times are GMT -8. The time now is 01:43 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.