Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Get template filename from pageid

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-11-2005, 01:59 PM
 
raulcarvalho raulcarvalho is offline
 

Newbie
  
Join Date: Aug 2004
Posts: 9
 

Default 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
Reply With Quote
  #2  
Old 03-14-2005, 03:25 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

wouldnt it be better to give your pages a more descriptive name in the first place ?
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 03-14-2005, 05:42 AM
 
raulcarvalho raulcarvalho is offline
 

Newbie
  
Join Date: Aug 2004
Posts: 9
 

Default 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!
__________________
Raul Carvalho
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:32 PM.

   

 
X-Cart forums © 2001-2020