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)
-   -   Adding a page with my own PHP Code (https://forum.x-cart.com/showthread.php?t=71082)

Black5ive 01-29-2015 08:02 AM

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

totaltec 01-29-2015 03:11 PM

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}


Black5ive 01-30-2015 06:33 AM

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

totaltec 02-01-2015 04:32 AM

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?


All times are GMT -8. The time now is 08:51 AM.

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