[SOLVED]Single Page Website using CMSMS 2.0

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

[SOLVED]Single Page Website using CMSMS 2.0

Post by maetmar »

Hello,

in the past I was using the "menu" module with the following template to create my single page websites.
Basically, the template parsed through all content pages and rendered them on the main page, where I called the "menu" with this template below.
NOw the problem is, that in CMSMS 2.0.1.1 this does not work anymore.
I get a an error:
ERROR: at line 412 in file /home/xxx/www.xxx-xxx.xx/cmsms/lib/smarty/sysplug ... curity.php:
Message: URI 'http://www.xxx-xxx.xxx/cmsms/index.php? ... plate=true' not allowed by security setting

Does anyone have an idea what needs to be changed to make it work again? Or is there any other approach to create a single page website where I have multiple content pages that are rendered to one single page on the frontend?

thanks for the help

that is the template I used:
{assign var='number_of_levels' value=10000}
{if isset($menuparams.number_of_levels)}
{assign var='number_of_levels' value=$menuparams.number_of_levels}
{/if}

{if $count > 0}

{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}

{elseif $node->depth < $node->prevdepth}


{elseif $node->index > 0}
{/if}

{if $node->parent == true or $node->current == true}
{assign var='classes' value='menuactive'}
{if $node->parent == true}
{assign var='classes' value='menuactive menuparent'}
{/if}
{if $node->children_exist == true and $node->depth < $number_of_levels}
{assign var='classes' value=$classes|cat:' parent'}
{/if}

{elseif $node->children_exist == true and $node->depth < $number_of_levels and $node->type != 'sectionheader' and $node->type != 'separator'}

{elseif $node->type == 'separator'}
<div class="divider"></div>
{else}

{capture assign=url}{$node->url}&showtemplate=true{/capture}
{fetch file="$url"}

{/if}

{/foreach}

{/if}
Last edited by maetmar on Wed Oct 21, 2015 3:36 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Single Page Website using CMSMS 2.0

Post by Jo Morg »

{capture assign=url}{$node->url}&showtemplate=true{/capture}
{fetch file="$url"}
A few things come to mind:
  1. $showtemplate = true; is the default behavior of CMSMS when responding to a request... that shouldn't be needed unless I'm missing something;
  2. {capture assign=url}{$node->url}&showtemplate=true{/capture} is not a very efficient way ti assign a string to a Smarty variable (particularly since Smarty 3.x);
  3. {fetch file="$url"} wasn't already a good way to do this before but I believe we closed that door (for security reasons) since CMSMS 1.12+. And here is where it drops the ball;
One of the ways of doing this (and it works well enough because we are talking about a single page site and you should have the Smarty cache active by default) is to use CGSimpleSmarty and it's get_page_content() method (see the module help) to do it with less issues.
My 2 cents...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Single Page Website using CMSMS 2.0

Post by velden »

CGSimpleSmarty and it's get_page_content() method
Alternatively have a look at the 'page_attr' plugin available by default in CMSMS 2.0 with enhanced functionality (compared to some earlier versions)
Help for the page_attr tag
What does this do?

This tag can be used to return the value of the attributes of a certain page.
How do I use it?

Insert the tag into the template like: {page_attr key="extra1"}.
What parameters does it take?

(optional) page (int|string) - An optional page id or alias to fetch the content from. If not specified, the current page is assumed.
key [required] The key to return the attribute of.

The key can either be a block name, or from a set of standard properties associated with a content page. The accepted standard properties are:
_dflt_ - (string) The value for the default content block (also known as content_en).
title
description
created_date - (string date) Date of the creation of the content object.
modified_date - (string date) Date of the last modification of the content object.
last_modified_by - (int) UID of the user who last modified the page.
owner - (int) UID of the page owner.
image - (string) The path to the image assocated with the content page.
thumbnail - (string) The path to the thumbnail assocated with the content page.
extra1 - (string) The value of the extra1 attribute.
extra2 - (string) The value of the extra2 attribute.
extra3 - (string) The value of the extra3 attribute.
(optional) assign (string) - Assign the results to a smarty variable with that name.

Returns:

string - The actual value of the content block from the database for the specified block and page.

Note: - The output of this plugin is not passed through smarty or cleaned for display. If displaying the data you must convert string data to entities, and/or pass it through smarty.
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

Re: Single Page Website using CMSMS 2.0

Post by maetmar »

thanks for your replies.
the problem with both provided solutions is that it will only work, if individual sections of the single page website are all using the same template structure, as it just includes the content_blocks of a given other page.
The good thing about my old way of doing it (although maybe not super performant or secure) was, that each page (=section of the single page website) was rendered using it´s own smarty template.
any ideas how to achieve that?
so basically I want one main page, that includes the full rendered HTML of other pages.
any ideas how to achieve that?
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Single Page Website using CMSMS 2.0

Post by JohnnyB »

Not sure if it is helpful, but you can now keep smarty templates on your web server as flat files. For example, you can have a "my-custom-smarty-template.tpl" with CMSMS and Smarty tags located in your file system and then include that into a template that is part of the Design Manager.

You'll need to enable this feature by adding the correct config rule to your config.php file. Look for $config['assets_path'] in the config. You can use the default location which is /tmp

Inside of your assets directory, you will need a directory called "templates"

For example, if you set $config['assets_path'] = 'assets'
you will need to have /assets/templates and your template files should be placed inside of that directory. Then, you can use a Smarty include file to pull in and parse its contents. Just be aware that there could be minor variable and scope issues to consider depending upon your needs.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Single Page Website using CMSMS 2.0

Post by velden »

maetmar wrote:thanks for your replies.
the problem with both provided solutions is that it will only work, if individual sections of the single page website are all using the same template structure, as it just includes the content_blocks of a given other page.
The good thing about my old way of doing it (although maybe not super performant or secure) was, that each page (=section of the single page website) was rendered using it´s own smarty template.
any ideas how to achieve that?
so basically I want one main page, that includes the full rendered HTML of other pages.
any ideas how to achieve that?
Consider using ajax to dynamically load the separate sections (=pages). You could then even implement something like 'endless scroll' to make it more 'efficient'.
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

Re: Single Page Website using CMSMS 2.0

Post by maetmar »

actually this post is about the same thing that I wanted to achive:
http://forum.cmsmadesimple.org/viewtopi ... t=%7Bfetch

I tried now with: {cge_cached_url url="$node->url"}
but it just stops proessing there without any error
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Single Page Website using CMSMS 2.0

Post by calguy1000 »

See documentation about the permissive_smarty config entry that is provided in the docs folder.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

Re: Single Page Website using CMSMS 2.0

Post by maetmar »

added $config['permissive_smarty'] = 1;
but that does not change anything
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: Single Page Website using CMSMS 2.0

Post by Jo Morg »

maetmar wrote:in the past I was using the "menu" module with the following template to create my single page websites.
Basically, the template parsed through all content pages and rendered them on the main page, where I called the "menu" with this template below.
NOw the problem is, that in CMSMS 2.0.1.1 this does not work anymore.
I get a an error:
ERROR: at line 412 in file /home/xxx/www.xxx-xxx.xx/cmsms/lib/smarty/sysplug ... curity.php:
Message: URI 'http://www.xxx-xxx.xxx/cmsms/index.php? ... plate=true' not allowed by security setting
maetmar wrote:added $config['permissive_smarty'] = 1;
but that does not change anything
If your method was working with CMSMS 1.12.x, permissive_smarty would make it work again. Just make sure that you are using the same setup you were using before and have cleared the cache. However if it wasn't working in CMSMS 1.12.x, you'd have to find a different approach. There are some changes that have been made for CMSMS 1.12 security policies that permissive_smarty won't have an effect on.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

Re: Single Page Website using CMSMS 2.0

Post by maetmar »

yes, you are right.
my previous post was related to the trial with {cge_cached_url url="$node->url"}, that did not work.
but the original approach now works again.
thanks that solves my issue
Post Reply

Return to “CMSMS Core”