Can I do a PHP include for front end?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
MarkP
Forum Members
Forum Members
Posts: 11
Joined: Wed Dec 17, 2008 5:00 pm

Can I do a PHP include for front end?

Post 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!!
User avatar
duclet
Forum Members
Forum Members
Posts: 187
Joined: Fri Jun 23, 2006 12:55 pm

Re: Can I do a PHP include for front end?

Post 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.
MarkP
Forum Members
Forum Members
Posts: 11
Joined: Wed Dec 17, 2008 5:00 pm

Re: Can I do a PHP include for front end?

Post 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!!!!
Coldman
Power Poster
Power Poster
Posts: 318
Joined: Sun Jun 22, 2008 5:33 am

Re: Can I do a PHP include for front end?

Post 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
Important Code of Conduct
Why don't use CMSMS Docs or search?
Do you read Help?
Admin for Swedish Translations Team
Moderator Swedish Forum
After your problem is solved, push the green button
MarkP
Forum Members
Forum Members
Posts: 11
Joined: Wed Dec 17, 2008 5:00 pm

Re: Can I do a PHP include for front end?

Post 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!
Pierre M.

Re: Can I do a PHP include for front end?

Post 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.
MarkP
Forum Members
Forum Members
Posts: 11
Joined: Wed Dec 17, 2008 5:00 pm

Re: Can I do a PHP include for front end?

Post by MarkP »

Thank Pierre!

I now have Singapore gallery in the CMS, http://cms2.webentia.net/index.php?page=sgal&gallery=TEST
Post Reply

Return to “Developers Discussion”