Page 1 of 1

[SOLVED]Single Page Website using CMSMS 2.0

Posted: Fri Oct 16, 2015 1:20 pm
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}

Re: Single Page Website using CMSMS 2.0

Posted: Fri Oct 16, 2015 1:49 pm
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...

Re: Single Page Website using CMSMS 2.0

Posted: Fri Oct 16, 2015 2:41 pm
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.

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 1:05 pm
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?

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 1:35 pm
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.

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 1:44 pm
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'.

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 1:59 pm
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

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 2:50 pm
by calguy1000
See documentation about the permissive_smarty config entry that is provided in the docs folder.

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 3:08 pm
by maetmar
added $config['permissive_smarty'] = 1;
but that does not change anything

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 3:19 pm
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.

Re: Single Page Website using CMSMS 2.0

Posted: Wed Oct 21, 2015 3:35 pm
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