Page 1 of 1

Inserting php into welcome screen

Posted: Thu Oct 13, 2011 8:48 pm
by Scribe
Hi guys,

Whenever I attempt to insert a php line into the welcome screen module, it appears to comment it out, i.e.:

<?php include '../rss/rss2html.php'; ?>

becomes

<!--?php include '../rss/rss2html.php'; ?-->

Any ideas how to accomplish this?

Many thanks

Re: Inserting php into welcome screen

Posted: Thu Oct 13, 2011 10:19 pm
by uksitebuilder
You cannot enter HP directly in to modules via the admin interface.

Edit the template files directly

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 1:54 am
by Scribe
uksitebuilder wrote:You cannot enter HP directly in to modules via the admin interface.

Edit the template files directly
The only problem is that it needs mixing in with the welcome message, I'd lose the ability to edit the message, which is fine for me but not other cart users.

I've added config.protectedSource.push( /<\?[\s\S]*?\?>/g ); to the CKEditor config file which prevents the admin panel from commenting out the code but when it comes time to display it on the front page of the site it still comments it out. Am I missing something here?

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 2:44 am
by Xsecrets
how many people are you going to have editing the admin of your cart and using php to do it? If you really have that many people doing it then it's an even more important security feature, which is why you can't do it in the first place. It's dangerous.

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 6:03 am
by Scribe
Xsecrets wrote:how many people are you going to have editing the admin of your cart and using php to do it? If you really have that many people doing it then it's an even more important security feature, which is why you can't do it in the first place. It's dangerous.
I will be putting the php in place but other editing will be of other visual elements, it's the ease of access that's important. I'm quite happy with the security element of those who have access to it. It's not about number of people, it's about me not wanting to give ftp access and just one person not being comfortable with editing and uploading files isn't good enough.

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 4:46 pm
by uksitebuilder
Well there is nothing out of the box to do this, no extensions that I know of

You would need to get a developer to add this functionality.

Maybe post on the Commercial Support forum or contact a Partner from our Partners page

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 6:56 pm
by SXGuy
i read somewhere of a plugin to ckeditor allowing php tags to be used, i tried it but failed to get it to work.

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 6:58 pm
by uksitebuilder
That's because OpenCart sanitizes the code before it reaches the database

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 8:00 pm
by spikeachu
Can you enter something like ##PHP_HERE## in the ckeditor then use str_replace in the controller?

Re: Inserting php into welcome screen

Posted: Fri Oct 14, 2011 8:34 pm
by uksitebuilder
That would simply print out the php code to screen

You would have to str_replace and then eval the result which i highly advise against for security reasons - eval() is evil!

Re: Inserting php into welcome screen

Posted: Sat Oct 15, 2011 12:55 am
by spikeachu
Sorry, I wasn't clear.

I meant to run your PHP code within the controller, then output the result (not the actual code) to the desired place by putting a place holder in ckeditor.

I agree, using eval gets messy and problematic.