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

Adding a page with my own PHP Code

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-29-2015, 08:02 AM
 
Black5ive Black5ive is offline
 

Newbie
  
Join Date: Jan 2015
Posts: 2
 

Default Adding a page with my own PHP Code

Hi,

I just started using X-Cart a few days ago. So far so good for the most part. I currently have a site which sells just one product. (http://www.taxiguitarproducts.com) I'm adding some more products so I'm setting up a cart.

A feature on the current site is a side bar element that displays guitarist's birthdays from a database I compiled. I'd like to add this as a page on my x-cart site. I've added a menu item and a page, but I don't see an obvious way to add the code that works.

Can this be done? is there some special markup that need to be included? It's pretty straight forward stuff. It's only about 100 lines of code.

I thank you in advance for your help.

Nick Paonessa
__________________
Nick Paonessa
BlackFive Media Inc.
Reply With Quote
  #2  
Old 01-29-2015, 03:11 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Adding a page with my own PHP Code

Well, you need to include your PHP script. Finding a good place to put your include can be a challenge.

It sounds like you are using a static page, perhaps pages.php would be a good place to place your include. Then in your php file, you need to assign the array or variable that you want to reference to smarty, the template engine.

Code:
$smarty->assign('guitarists', $guitarists);

Then you can reference it in you page, assuming that you have checked the box to "Parse Smarty tags in the content of embedded pages" in the pages section of the admin.

Then you can build a foreach loop to loop through your array.

Code:
{foreach from=$guitarists item=guitarist} Name:{$guitarist.name} Birthday:{$guitarist.birthday} {/foreach}
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 01-30-2015, 06:33 AM
 
Black5ive Black5ive is offline
 

Newbie
  
Join Date: Jan 2015
Posts: 2
 

Smile Re: Adding a page with my own PHP Code

Thank you for your reply TotalTec. I could not get your solutions to work, but I thank you for your suggestion. I learned a couple of things in trying to implement it and your suggestion did lead me to a solution.

I think I found a way around it.

I created a separate page on my server with just the PHP in it. (guitarists-bday.php) Then in the empty X-Cart page, I referenced that page in an iframe tag.

<p><iframe src="/guitarists-bday.php" width="500" height="500" frameborder="0" scrolling="no"> </iframe></p>

It's not elegant but it works.

Thanks again.

Nick Paonessa
__________________
Nick Paonessa
BlackFive Media Inc.
Reply With Quote
  #4  
Old 02-01-2015, 04:32 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Adding a page with my own PHP Code

Nick, sure an Iframe can work for anything.

What problems did you have exactly? Including your file? Assigning the variables to smarty? Rendering the html in your static page?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
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:10 PM.

   

 
X-Cart forums © 2001-2020