How to add a custom page ? - Ecommerce x PrestaShop - PrestaShop

Jump to content

Photo

How to add a custom page ?

#1

Posted 25 April 2010 - 04:06 PM

Sly Crespo

    PrestaShop Newbie

  • Members
  • Pip
  • 20 Active Posts
Hello ! I'm new to PrestaShop and that question may be stupid.
I would like to add a custom page to my shop and a corresponding link on the top of the page. How do I do this ?
Thanks

#2

Posted 25 April 2010 - 05:14 PM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
You could go to Back Office » Tools » CMS and click on Add new.
And use some module to add it to homepage.

Another way is to create for example newpage.php
<?phpinclude(dirname(__FILE__).'/config/config.inc.php');include(dirname(__FILE__).'/header.php');$smarty->display(_PS_THEME_DIR_.'newpage.tpl');include(dirname(__FILE__).'/footer.php');?>

and save it to main prestashiop folder and then in your theme folder create file newpage.tpl.


Both files are in attachment.

Attached Files



#3

Posted 25 April 2010 - 05:40 PM

Sly Crespo

    PrestaShop Newbie

  • Members
  • Pip
  • 20 Active Posts
Thanks razaro for your fast reply... But i'm a noob and don't know how to do that.. Can you explain it a little bit more precisely. Sorry about my english and Thanks.
Sly

#4

Posted 26 April 2010 - 01:00 AM

ladivito

    PrestaShop Apprentice

  • Members
  • PipPip
  • 316 Active Posts
useful tips.....thanks :)

#5

Posted 30 October 2010 - 05:45 PM

sircolla

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
hello razaro,
could you tell me which module to use to add new pages?
thanks

#6

Posted 30 October 2010 - 06:01 PM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
You can add links to new pages with some modules, if you create CMS page you can use Info block module and if you created php page use Link block module.
And this module can do both.

#7

Posted 30 October 2010 - 06:05 PM

sircolla

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
thanks for your reply i have already done it.Once again Thank you

#8

Posted 02 November 2010 - 06:05 AM

t7E4n5L1

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
I'm able to do what razaro suggested but I need that the page switches to a different language when the user click on the country flag. So 'newpage.php?id_lang=1' and 'newpage.php?id_lang=2' load the right translation of that page. Could you help me?

#9

Posted 02 November 2010 - 07:00 AM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
I don't know how you page looks like but for every text you display and want to be able to translate you need to use function l .

If you have php file
$this->l('Some text')

and in tpl file
{l s='Some text' }


And use translate tool in back office. That should be enough so when you change language text will change too.

#10

Posted 02 November 2010 - 07:54 PM

t7E4n5L1

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
Somehow, using {l s='Some text' } in my tpl file renders the code (it's a table with js animation) unreadable. Is there a way to just redirect to a different page based on language selection?

#11

Posted 02 November 2010 - 07:59 PM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
Try to add this code

include(dirname(__FILE__).'/init.php');


So page looks like
<?phpinclude(dirname(__FILE__).'/config/config.inc.php');include(dirname(__FILE__).'/init.php');include(dirname(__FILE__).'/header.php');$smarty->display(_PS_THEME_DIR_.'newpage.tpl');include(dirname(__FILE__).'/footer.php');?>


#12

Posted 02 November 2010 - 09:12 PM

t7E4n5L1

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
My .php page already has this code in it
$smarty->display(_PS_THEME_DIR_.'newpage.tpl');


I think the problem is in inserting the js into the header
[removed][removed][removed][removed]


I'm not sure where this goes to be read. This is what my header.tpl looks like.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html >    <head>        <title>{$meta_title|escape:'htmlall':'UTF-8'}</title>{if isset($meta_description) AND $meta_description}        <meta name="description" content="{$meta_description|escape:html:'UTF-8'}" />{/if}{if isset($meta_keywords) AND $meta_keywords}        <meta name="keywords" content="{$meta_keywords|escape:html:'UTF-8'}" />{/if}        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />        <meta name="generator" content="PrestaShop" />        <meta name="robots" content="{if isset($nobots)}no{/if}index,follow" />        <link rel="icon" type="image/vnd.microsoft.icon" href="{$img_ps_dir}favicon.ico" />        <link rel="shortcut icon" type="image/x-icon" href="{$img_ps_dir}favicon.ico" />{if isset($css_files)}    {foreach from=$css_files key=css_uri item=media}    <link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />    {/foreach}{/if}        [removed][removed]        [removed]            var baseDir = '{$content_dir}';            var static_token = '{$static_token}';            var token = '{$token}';            var priceDisplayPrecision = {$priceDisplayPrecision*$currency->decimals};            var roundMode = {$roundMode};        [removed]        [removed][removed]        [removed][removed]        [removed][removed]        {if isset($js_files)}    {foreach from=$js_files item=js_uri}    [removed][removed]    {/foreach}{/if}        {$HOOK_HEADER}    </head>        <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>    {if !$content_only}        <noscript><ul><li>{l s='This shop requires JavaScript to run correctly. Please activate JavaScript in your browser.'}</li></ul></noscript>        <div id="page">            <!-- Header -->            <div id="header">                <div id="header_wrapper">                    <div id="header_top">                        <h1 id="logo"><a href="{$base_dir}" title="{$shop_name|escape:'htmlall':'UTF-8'}"><img src="{$img_ps_dir}logo.png" alt="{$shop_name|escape:'htmlall':'UTF-8'}"></a></h1>                        {$HOOK_TOP}                    </div>                </div>            </div>            <!-- Center -->            <div id="main_content">                <div id="content_wrapper">                    <div id="center_column">    {/if}


#13

Posted 02 November 2010 - 10:30 PM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
Could you zip relevant files (newpage tpl header tpl ..) and attach it to your post?

If you use some custom js code surround it with
{literal} .....{/literal}


Also to turn debug mode on change in config/config.inc.php
/* Debug only */@ini_set('display_errors', 'on');

to help you find any errors you might have.

#14

Posted 03 November 2010 - 01:02 PM

t7E4n5L1

    PrestaShop Newbie

  • Members
  • Pip
  • 6 Active Posts
Basically, this is what I'm trying to implement in the newpage.tpl

http://css-tricks.co...mples/InfoGrid/

I'm currently loading the page with an iframe. It works but I'd like something smoother.

Whenever I try to call a javascript file, it seems to break the js for the whole page so I must be doing it wrong or putting it in the wrong location.

#15

Posted 13 May 2011 - 07:11 AM

herbalpazar

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts
Hi,
I'm using the theme of healthy. TemplateMonster 32552, newpage.tpl and newpage.php files installed. But another process to create a new page than I do myself?
note: the theme to activate it, I am installing dump.sql file.

#16

Posted 11 November 2011 - 11:08 PM

devilsown

    PrestaShop Apprentice

  • Members
  • PipPip
  • 387 Active Posts
I am trying to add some js to this test file. I know i can put.

<script language="javascript" src="testjsfile.js">
</script>



But how would i include it so CCC will include it?

in a modual i know i would do it this way.

public function hookHeader($params)
{
  Tools::addJS(($this->_path).'testjsfile.js');
}

deleted by moderator....

#17

Posted 12 November 2011 - 10:13 PM

razaro

    PrestaShop Fanatic

  • SPAM Mod
  • PipPipPipPip
  • 1390 Active Posts
One way to create new custom page in version 1.4.x is :

1.Create new controller for custom page.

NewPageController.php
<?php

class NewPageControllerCore extends FrontController
{
  public $php_self = 'new-page.php';

  public function setMedia()
  {
		  parent::setMedia();
		  Tools::addCSS(_THEME_CSS_DIR_.'new-page.css');
		  Tools::addJS(_THEME_JS_DIR_.'new-page.js');
  }

  public function displayContent()
  {
		   parent::displayContent();
		   self::$smarty->display(_PS_THEME_DIR_.'new-page.tpl');
  }
}

NewPageController.php should be placed in controllers folder.
In function setMedia() js ad css files are called from theme directory js and css folders for example,
but here also can be used _PS_CSS_DIR_ and _PS_JS_DIR_ for calling files from root
js and css directories.



2.Create new custom page

new-page.php
<?php

require(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('NewPageController')->run();


new-page.php should be placed in root directory (with the rest of php files)

3.Create tpl file for new page

new-page.tpl

{capture name=path}{l s='NewPage'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}

<h1>{l s='Custom new page'}</h1>

new-page.tpl should be placed in theme folder.

And that is not too hard, right :-)
And replace NewPage and new-page with page name you want.
Just follow class NewPageControllerCore -> getController('NewPageController'),
new-page.php -> new-page.tpl.

One more thing do is in Back Office > Preferences > SEO & URLs , click on Add new,
select custom new page (new-page.php) and fill rest of data and regenerate .htaccess file.
Then instead going to website.com/new-page.php for example following could be used
website.com/custom-new-page .

Edited by razaro, 26 June 2012 - 05:06 PM.


#18

Posted 14 February 2012 - 12:31 PM

benconnekt

    PrestaShop Newbie

  • Members
  • Pip
  • 10 Active Posts
Hi razaro,

Thanks for the guide, I have followed the instructions and was able to create a new page. However, the content I entered from the tpl file is not displayed. Also I will like to be able to edit the content from back office

#19

Posted 15 February 2012 - 11:15 PM

environs

    PrestaShop Newbie

  • Members
  • Pip
  • 3 Active Posts
Sure it is a useful guide, Although followed the steps here I created a new page, but the content from the tpl file is not displayed.
Unique Gifts from Peru

#20

Posted 06 March 2012 - 01:21 PM

sixthmind

    PrestaShop Apprentice

  • Members
  • PipPip
  • 95 Active Posts
Thanks so much. It works great for me, but what does it mean:
{capture name=path}{l s='NewPage'}{/capture}



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more