This article describes how to add a link to the Information sidebox that links to a new page in the defined pages section. You will be required to create files, modify files, and insert SQL code into the MySQL database.
In the instructions below yourpage or YOURPAGE is the title of the page you are adding. For instance if you wanted to add one called technology you would replace YOURPAGE and yourpage with technology and TECHNOLOGY. The actual file would be technology.php.
1. Modify File:
Modify the following file <zencart-root>/includes/filenames.php by adding the following two lines of code:
- define('FILENAME_DEFINE_YOURPAGE', 'define_yourpage');
- define('FILENAME_YOURPAGE', 'yourpage');
above…
- define('FILENAME_DEFINE_PRIVACY', 'define_privacy');
- define('FILENAME_PRIVACY, 'privacy');
…respectively.
2. Modify File:
Modify the following file <zencart-root>/includes/languages/custom_template/english.php if you are using a custom template. Add the below line of code:
- define('BOX_INFORMATION_YOURPAGE', 'YourPage');
above…
- define('BOX_INFORMATION_PRIVACY', 'Privacy');
3. Modify File:
Modify <zencart-root>/includes/languages/english.php. Add the below line:
- define('BOX_INFORMATION_YOURPAGE', 'YourPage');
above…
- define('BOX_INFORMATION_PRIVACY', 'Privacy');
4. Copy and Modify File:
Copy <zencart-root>/includes/languages/english/page_2.php to <zencart-root>/includes/languages/yourpage.php. Then modify the newly created yourpage.php by editing line #20 to something like the following.
- // $Id: yourpage.php 1969 2005-09-13 06:57:21Z drbyte $
Also modify the text below for NAVBAR_TITLE, HEADING_TITLE, and TEXT_INFORMATION to state whatever you would like to so it represents your new PHP page.
5. Create Directory:
Create a new yourpage directory using the command specified below.
- touch <zencart-root>/includes/modules/pages/yourpage
6. Copy and Modify File:
Now copy these files using the syntax below. Then modify this newly created file by editing line #14 with the text below the cp command.
- cp -p <zencart-root>/includes/modules/pages/page_2/header.php <zencart-root>/includes/modules/pages/yourpage/header.php
- $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_YOURPAGE, 'false');
7. Modify File:
Modify <zencart-root>/includes/modules/sideboxes/information.php by adding the three lines of code below:
- if (DEFINE_YOURPAGE_STATUS <= 1) {
- $information[] = '<a href="' . zen_href_link(FILENAME_YOURPAGE) . '">' . BOX_INFORMATION_YOURPAGE . '</a>';
- }
above…
- if (DEFINE_CONDITIONS_STATUS <= 1) {
- [/sourcecode]
- <strong></strong>
- <strong>8. Copy and Modify:</strong> Copy the below template file and then modify lines #9, #15, and #19 with the code below the copy command.
- [sourcecode language='sh']
- cp -p <zencart-root>/includes/templates/templates_default/templates/tpl_privacy_default.php <zencart-root>/includes/templates/templates_default/templates/tpl_yourpage_default.php
#2
- * @version $Id: tpl_yourpage_default.php 3464 2006-04-19 00:07:26Z ajeh $
#15
- <?php if (DEFINE_YOURPAGE_STATUS >= 1 and DEFINE_YOURPAGE_STATUS <= 2) { ?>
#19
- * require the html_define for the yourpage page
9. Modify FIle:
Modify <zencart-root>/includes/templates/templates_default/templates/tpl_site_map_default.php by adding the below three lines of code:
- <?php if (DEFINE_YOURPAGE <= '1') { ?>
- <li><?php echo '<a href="' . zen_href_link(FILENAME_YOURPAGE) . '">' . BOX_INFORMATION_YOURPAGE . '</a>'; ?></li>
- <?php } ?>
above…
- <?php if (DEFINE_CONDITIONS_STATUS <= '1') { ?>
10. Modify File:
Modify <zencart-root>/admin/includes/languages/english.php by adding the following code:
- define('BOX_TOOLS_DEFINE_RETURNS','YOURPAGE');
above
- define('BOX_TOOLS_DEFINE_PRIVACY','Privacy');
11. Modify File:
Modify <zencart-root>/admin/includes/languages/english/define_pages_editor.php by adding the below code
- define('TEXT_INFO_RETURNS', 'YourPage');
above…
- define('TEXT_INFO_PRIVACY', 'Privacy');
12. Copy and Modify File: Copy the below file and then modify the newly created file by adding the below text to the file.
- cp -p <zencart-root>/includes/languages/english/html_includes/define_privacy.php <zencart-root>/includes/languages/english/html_includes/define_yourpage.php
Please modfy via the Define Pages admin located under the Tools navigation in the menu.
13. Modify the Database:Copy/Paste the below SQL code into the following part of the ZenCart admin section for your site: Tools >> Install SQL Patches
Code to Install:
- INSERT INTO `configuration` ( `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`)
- VALUES ('Define yourpage', 'DEFINE_YOURPAGE_STATUS', '1', 'Enable the Defined yourpage Link/Text?<br />0=Link ON, Define Text OFF<br />1= Link ON, Define Text ON<br />2= Link OFF, Define Text ON<br />3= LinkOFF, Define Text OFF', 25, 100, NOW(), NOW(), NULL, 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3''),');
14. Edit Page In Admin: Open up the ZenCart admin section and navigate to Tools >> Define Pages Admin. In the first drop down choose define_yourpage.php, type the content, and click the save button at the bottom right of the screen.
You now have defined a new page to appear in the information box above the Privacy link and below the Shipping Info link. You can create as many pages as needed and if you need them located in different areas of the site you can substitute the above information for each such location.
If you really want to learn your way around ZenCart I suggest purchasing the book below. Not only will it serve as a great resource while building out your store but it also helps support the project by putting some of the money from the purchase into it.
I followed all of these instructions, and it did not work. Can you verify this works with Zen Cart v1.5.1? Thanks!
Hello Aurora,
It is very possible that things have changed as this article was written four years back. I haven’t had the need to use ZenCart in quite some time so when you do find resolution let us know what it is and I will update the article.
Thanks.
alex
This work on ZC 1.5.1. but…
there is some confusion in the published code…
After step 10 there are some wrong indications and this generates errors.
define(‘BOX_TOOLS_DEFINE_RETURNS’,’YOURPAGE’);
and anywhere there is _DEFINE_* must be corrected to point to “your page”
ie:
define(‘BOX_TOOLS_DEFINE_YOURPAGE’,’YOURPAGE’);
define(‘TEXT_INFO_YOURPAGE’, ‘YourPage’);
Hope this helps