Forums / Addon Sideboxes / Am unable to insert PHP code into newly installed Blank Sidebox

Am unable to insert PHP code into newly installed Blank Sidebox

Locked

Views: 2,037

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
23 Apr 2010, 8:56 AM
#1
dave_mc avatar

dave_mc

New Zenner

Join Date:
Apr 2007
Location:
Coventry, West Midlands
Posts:
36
Plugin Contributions:
0

Am unable to insert PHP code into newly installed Blank Sidebox

Can anybody help me please. I am having difficulty inserting the following PHP code into my newly installed Blank Sidebox.

Code that I require within the Sidebox:

<?php /** Social bookmarking / social shopping links - by That Software Guy @copyright Copyright That Software Guy, 2006-2007 @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 **/ $linktitle = STORE_NAME; $linktitle = urlencode($linktitle); $linkpath = HTTP_SERVER . DIR_WS_CATALOG; while (strstr($linkpath, '&')) $linkpath = str_replace('&', '&', $linkpath); $linkpath = urlencode($linkpath); define('SOCIAL_NETWORKING_MAIN_PAGE', '1'); ?> <?php require($template->get_template_dir('tpl_social.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_social2.php'); ?>

This is my template file:

<?php /** * blank sidebox - allows a blank sidebox to be added to your site * * @package templateSystem * @copyright 2007 Kuroi Web Design * @copyright Portions Copyright 2003-2007 Zen Cart Development Team * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: blank_sidebox.php 2007-05-26 kuroi $ */ $content = ''; $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">'; // Replace the text and HTML tags between the apostophes on lines 19 and 20. // Use as many or as few lines using this model as you need for your custom content. // If you have a multilingual site define your text in the languages/YOUR_LANGUAGE/extra_definitions/blank_sidebox_defines.php and include it as shown in line 19. // If your site is monolingual, you can put the text right here as shown on line 20 (and nobody will know!) $content .= '<p>' . TEXT_BLANK_SIDEBOX . '</p>'; $content .= '<p>You can include text, links, images, HTML markup and even PHP code</p>'; $content .= '</div>'; ?>

When I replace the text in red with the above PHP code it doesn't work - can anybody please tell me where I'm going wrong.:dontgetit

23 Apr 2010, 1:23 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Am unable to insert PHP code into newly installed Blank Sidebox

The code you show is for a module file, which calls a particular template file. It cannot be inserted into a template file as-is, in three ways.
First, the <?php and ?> tags around it need to be stripped off if you are inserting it inside a PHP section like the blank sidebox code.
Second, the "require" statement would be redundant and need to be removed if the code were inserted in a tpl_ file.
Third, $linktitle and $linkpath are not variables that would be handled by a standard sidebox output file, so the content would never be output by it - it would need to be converted into contents of the $content variable. Also, the code given would only generate links to the store's homepage, not interact with social bookmarking sites, so it is incomplete and needs a bunch more code to have useful functionality.

This code originally had a specific template file associated with it to handle its output, and without knowing how it was intended to work there is no way to insert it here. I think it was not intended to go into a sidebox in its current form.