Page 1 of 1
Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 5:08 pm
by MarkP
Hello to the great devs at CMS Made Simple,
I am testing the script to be used by our local Arts Council and so far it has met our needs.
However I would like to ask the dev people if it is possible to do a PHP include to include a photo gallery PHP script.
The gallery that comes with CMSMS is great but I would like to include another gallery script. It is a flat file db script.
This is my test install of CMSMS
http://cms2.webentia.net/index.php
Thank you!!
Re: Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 5:12 pm
by duclet
You should be able to with the {php} {/php} keywords. You would be able to include PHP code within in. Just make sure your configurations allows you to do that.
Re: Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 5:26 pm
by MarkP
Thanks duclet,
Let me get this straight in my head, I would make a new page the do a:
Code: Select all
{php}<? include("script_name.php");?>{/php}
Configurations? - I searched the support about this.
Can you elaborate?
Thanks!!!!
Re: Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 5:46 pm
by Coldman
Hi MarkP!
You can find this in Wiki
Using {php} and {/php} Tags
The second way to include php code into your page is by using {php} and {/php} tags to surround your php code in your page or template (you do not need the tags with this syntax). However, this functionality is disabled by default on new installs.
To enable this functionality, you need to change one line of the config.php file in your installation. Change the "use_smarty_php_tags" setting to true. i.e.:
#Allow smarty {php} tags? These could be dangerous if you don't trust your users.
$config['use_smarty_php_tags'] = true;
Now you can place php code into your page or template at will. i.e.:
{php}phpinfo();{/php}
Note: This is not the recommended way of accomplishing this task, as any user with the ability to edit the page, or the template could edit the php code, and besides causing script errors, could potentially introduce security issues. Use a User-Defined tag instead.
Here's the link for that
http://wiki.cmsmadesimple.org/index.php/Developers_FAQ
Re: Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 7:15 pm
by MarkP
Thanks Coldman,
Just checked out the link you sent.
What I did was do my include in my UDT:
Code: Select all
include("folder/file1.php");
include("folder/file2.php");
I named it "sgal" and added {sgal} to the page.
Now I feel I am getting closer... now I just have some issues with the gallery script to work out But I must say that this Forum community is has been so helpful - I wasn't expecting an answer so quick.
If you want to see what I have so far >>
http://cms2.webentia.net/index.php?page=sgal
There are issues with the footer (a CSS conflict that I will work out later).
Also I was wondering how I could eliminate the Print page icon for certain pages?
Thanks
Coldman!
Re: Can I do a PHP include for front end?
Posted: Wed Dec 17, 2008 8:59 pm
by Pierre M.
Coldman wrote:
Using {php} and {/php} Tags
Note: This is not the recommended way of accomplishing this task, as any user with the ability to edit the page, or the template could edit the php code, and besides causing script errors, could potentially introduce security issues. Use a User-Defined tag instead.
Yes, use UDT instead. Don't let arbitrary users inject arbitrary code into your site.
MarkP wrote:
Also I was wondering how I could eliminate the Print page icon for certain pages?
Those pages simply need a template not including the unwanted stuff. Copy the template and edit the copy to remove it. Then assign the new template.
Pierre M.
Re: Can I do a PHP include for front end?
Posted: Thu Dec 18, 2008 5:12 pm
by MarkP