Post by Rattus » Sun Sep 05, 2010 12:18 am

**Disclaimer** I'm not a programmer and know enough to break things but, can follow directions***


Greeting all,

I've been searching and lurking around trying to find an answer to this and I see that it's been asked before.

I would like to add new content to my site that will display in the main content area like a information page or pretty much anything else.
The catch here is, I want to include some dynamic content at times. For this go-around I would like to include another script. This script (a plugboard) already has instructions for inclusion using <? include "path to script"; ?>.
I can not figure out a way to achieve this. I came across this : http://forum.opencart.com/viewtopic.php?f=112&t=18222 but, of course would rather not compromise security.

Any help or suggestions?

Thank you

Newbie

Posts

Joined
Mon Aug 23, 2010 12:13 am

Post by Xsecrets » Sun Sep 05, 2010 1:12 am

You won't be able to include other scripts without some sort of security implications.

I certainly would not recommend the solution from the other thread. If you really want to run php code in information pages you could change the following code in catalog/view/theme/default/template/information/information.tpl

Code: Select all

<?php echo $description; ?>

to

Code: Select all

<?php eval($description); ?>
then you can put php code into the information page the same way you put html code in.
There are security implications with this as well, but not nearly as severe as the solution from the other thread you linked.
you should research possible security issues with the use of eval() though.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Sun Sep 05, 2010 1:14 am

you can simply call that include tag in the catalog/view/theme/YOURTHEME/template/product/product.tpl page

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Rattus » Sun Sep 05, 2010 1:59 am

Thank you for the replies.

Xsecrets> It doesn't have to be a "Information" page per-say, but if that is an option I'll look into along with the suggestion of the research.

When I made that change, then went into the Admin area, select a info page or create a new one, the built-in editor removes the <? include "path to script"; ?>.
and the result was this:

Code: Select all

Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home/rattus/public_html/store/catalog/view/theme/default/template/information/information.tpl on line 10
Line 10 is were the change was made.




Qphoria>
Wouldn't that put it on every product page? That's not what I want.
I would like to have a completely separate page for reciprocal link/banner exchanging.

This is what I got when I tried to include it into the product.tpl

Code: Select all

Warning: include(http://rattydaddys.com/pub/plug.php) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/rattus/public_html/store/catalog/view/theme/default/template/product/product.tpl on line 259Warning: include(http://rattydaddys.com/pub/plug.php) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/rattus/public_html/store/catalog/view/theme/default/template/product/product.tpl on line 259Warning: include() [function.include]: Failed opening 'http://rattydaddys.com/pub/plug.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rattus/public_html/store/catalog/view/theme/default/template/product/product.tpl on line 259

So of course I'm missing something. I wish there was a mod for this sort of stuff.

Newbie

Posts

Joined
Mon Aug 23, 2010 12:13 am

Post by Qphoria » Sun Sep 05, 2010 2:02 am

So then add a conditional around it


<?php
if ($this->request->get['product_id'] = '1') {
include ('filename');
}
?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Sun Sep 05, 2010 2:52 am

Rattus wrote: When I made that change, then went into the Admin area, select a info page or create a new one, the built-in editor removes the <? include "path to script"; ?>.
I was afraid of that. I didn't check to see if the editor striped things like that or not. I knew the db input did not.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Rattus » Sun Sep 05, 2010 3:27 am

That works alright but, I want it on its own page.

Customer clicks on a links link and it's loaded in the main content area.
Qphoria wrote:So then add a conditional around it


<?php
if ($this->request->get['product_id'] = '1') {
include ('filename');
}
?>


Then back to Xsecrets suggestion:

What I don't understand is why isn't additional PHP info parsed. Is this a function of OC or the editor excluding such info or it's possible because the Table: information_description in the dB is set to text?
I even went into PHPMyAdmin and located the specific info page and put in the include. Nada...


bah..just talking out me butt.

Newbie

Posts

Joined
Mon Aug 23, 2010 12:13 am

Post by Xsecrets » Sun Sep 05, 2010 8:03 am

Rattus wrote: Then back to Xsecrets suggestion:

What I don't understand is why isn't additional PHP info parsed. Is this a function of OC or the editor excluding such info or it's possible because the Table: information_description in the dB is set to text?
I even went into PHPMyAdmin and located the specific info page and put in the include. Nada...


bah..just talking out me butt.
It didn't run php code that you put into the database after changing the view to use eval? I mean it does run html_entity_decode on it before passing it to the veiw, but I don't think that should affect things.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Rattus » Sun Sep 05, 2010 11:30 pm

Xsecrets wrote: It didn't run php code that you put into the database after changing the view to use eval? I mean it does run html_entity_decode on it before passing it to the veiw, but I don't think that should affect things.


Nope!

With <?php echo $description; ?> and adding the <? include "path to file"; ?> directly to the description field of Table: information_description through PHPMyAdmin, it is completly ignored and the page is blank. The line is in the page source though.

Changing the line to <?php eval ($description); ?> gives this result on ANY info page that's there.

Code: Select all

Parse error: syntax error, unexpected '<' in /home/rattus/public_html/store/catalog/view/theme/default/template/information/information.tpl(10) : eval()'d code on line 1
It does not like eval one bit.

Newbie

Posts

Joined
Mon Aug 23, 2010 12:13 am

Post by Famm35 » Thu Sep 15, 2011 8:22 am

simply create a information page and then turn the sort to -1 which doesnt show up in the information list on the front page....easy as that. Link to the custom page how ever you want

Newbie

Posts

Joined
Thu Sep 15, 2011 8:19 am
Who is online

Users browsing this forum: No registered users and 21 guests