Including php in a template


Is there a way to include PHP inside a template. For example something like this
<?php require_once '/pcw/shortcode.php'; ?>
Thank you


Code
:set_value('allow_php_in_templates', '1');
However I would not recommend it, as you're granting any theme you install in the future permission to run PHP code on your server.
You are better off writing and including a mini-block.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


I added the line you provided. Is there any special tags php needs to be wrapped into. Straight up is not working.




Did you edit your template after putting in the command?
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


That said, that code would need to be compatible - if it's pulled from some Wordpress addon it's almost certainly not going to work, it would need to be standalone PHP.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.


I guess the correct question I should have asked. Let's say I am creating a news article. Is there a way to include php in there?
Pretty sure the template will accept php after the command line addition, but that's not what I intended on asking.


You can easily include it via a block in Comcode.
Put your PHP code in sources_custom/miniblocks/shortcode.php
and include with [block]shortcode[/block]
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.




require_once '../pcw/shortcode.php';
So how do I call what I need into the [block]shortcode[/block] so that my php file is included in there? Is it a file name I have in the folder?


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.




So if my needed folder is in the public_html directory along with all composr folders. lets say called pcw.
What path do I use in my block for sources_custom/miniblocks
What do I need to change below?
require_once '../pcw/shortcode.php';


require_once 'pcw/shortcode.php';
Composr sets the current working directory to the root.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.




I am creating some PHP scripts for my co-workers to make their daily chores easier and now after reading this post I realize I can embed these tools into a COMPOSR and really make it look awesome!
I am wondering though, is a mini-module as talked about here:
Composr Tutorial: Writing mini-modules - Composr
the same as a mini-block you are discussing in this post?
Thanks much
Stevyn
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp




thinking I will try it first as a mini-module as it is pulling in many things to process. Basically it does a GIT clone, then some edits and a GIT push back. and some other items.
geeking out to try it tomorrow when back at the office :)
Publisher of IronFeather Journal since 1987. Host of KGNU Colorado Radio for 20 years.
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido: Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp


Mini-blocks and mini-modules are implemented in exactly the same way, i.e. you just code a pure PHP file without any real forced structure but have full access to Composr's API. Just a mini-block is a block and a mini-module is a module (a page, i.e. accessed by URL).
They are stored in different directories, sources_custom/miniblocks vs <zone>/pages/minimodules_custom.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.