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)
-   -   Create a New php Page? (https://forum.x-cart.com/showthread.php?t=17003)

Mr Bob 09-30-2005 06:29 PM

Create a New php Page?
 
I want to create a new php page that uses the template system of xcart.

I figured I could copy the contact us one, but it doesn't seem like it is going to work.

I don't believe I can start from scratch simply because I need to pass along the sessions and things like that.

Is there a page I can copy to start with, and then just create a few tpl files for the main content area? I want something similar to what appears on home.php, but there looks to be a lot of code inside that file that I would not want to use.

This has to have been answered in the past, but the search didn't turn up anything.

instinctual 10-03-2005 05:46 AM

If it were me I would copy the register.php and the include/register.php and work from there. You will notice the include/register.php is called into the root register.php, and they are working off of skin1/customer/main/register.tpl.

If you follow that setup, you should be fine with creating your own new php page ;o)

Keep in mind you can also do similar things with "static pages" - but not sure what your goal is. Working with the static pages would be much easier...

Mr Bob 10-03-2005 08:35 AM

Thanks! I will give the register pages a try.

My goal is just to have a page that uses the smarty template system, I figured a PHP page would be the best to do this.

Thanks again :lol:

Mr Bob 10-03-2005 12:53 PM

I think it is going to have way too much useless information.

The include/register.php page contains about 900 lines of php code :(


The reason why I did not want static pages is because I want to be able to use webmaster mode to make text changes.

Also, I don't see anywhere that tells register.php to use register.tpl template :(

Mr Bob 10-04-2005 11:31 AM

I would have thought a lot more people would have known how to do this. Here are all the steps:


1. Create 'new_page.php' file in the '<xcart_root_dir>' with the following content :

---------------------------------------
<?php
require "./auth.php";

# Assign Smarty variables and show template
$smarty->assign("main","new_page");

func_display("customer/home.tpl", $smarty);
?>
---------------------------------------

2. Open '<xcart_root_dir>/skin1/customer/home_main.tpl' template and add following code :

---------------------------------------
{elseif $main eq "new_page"}
{include file="new_page.tpl"}
---------------------------------------

after the following fragment:

---------------------------------------
{elseif $smarty.get.mode eq "unsubscribed"}
{include file="main/unsubscribe_confirmation.tpl"}
---------------------------------------

3. Then create 'request_catalog.tpl' template in the '<xcart_root_dir>/skin1/' folder with the following content:

---------------------------------------
{$lng.lbl_new_page}
---------------------------------------

Then, when the customer opens the 'new_page.php' URL the standard X-Cart page will appear with the '{$lng.lbl_brochures_text}' language variable text in the central area.

shan 10-04-2005 11:43 AM

dont forget to use the 'code' button when making a post. makes it much easier to read

Jon 10-04-2005 11:49 AM

You'll want to include your categories, etc., in your php file too. And set the location:

Code:

<?php

require "./auth.php";

require $xcart_dir."/include/categories.php";

if ($active_modules["Manufacturers"])
    include $xcart_dir."/modules/Manufacturers/customer_manufacturers.php";


if($active_modules["Bestsellers"])
        include $xcart_dir."/modules/Bestsellers/bestsellers.php";

$location[] = array(func_get_langvar_by_name("lbl_your_language_variable", ""));

#
# Assign Smarty variables and show template
#

$smarty->assign("main","newpage");

# Assign the current location line
$smarty->assign("location", $location);

func_display("customer/home.tpl",$smarty);
?>


Mr Bob 10-04-2005 01:11 PM

I didn't put each bit into code tags because I thought it would have looked horrible.

Jon, can you explain a bit about this code segment?

Code:

$location[] = array(func_get_langvar_by_name("lbl_your_language_variable", ""));


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

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