Number of {conent block} set in the page options???

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
booka
Forum Members
Forum Members
Posts: 18
Joined: Fri Jan 17, 2014 8:58 am

Number of {conent block} set in the page options???

Post by booka »

Hello there!

I had tried to add an option to set content block amount at the page options, but it seems parcer wouldn't allow me to do what I want. How this could be done?

Code: Select all

<!-- TEMPLATE BLOCKS --> 
{capture assign="magpagenumber"}{content block="magpagenumber" oneline="true" label="Number of magazine pages" page_tab='Header' wysiwyg='false'}{/capture}
<!-- END TEMPLATE BLOCKS -->

{if $magpagenumber > 0}
{section name=i loop=$magpagenumber} 
    {if $smarty.section.i.index is div by 2}
        <div class="mag-page-even">
    {else}
        <div class="mag-page-odd">
    {/if}
    {$i == $smarty.section.i.iteration} 
    {content block="{$i} page"}
    </div>
{/section} 
{/if}
It creates enough divs but only 1 content block.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: Number of {conent block} set in the page options???

Post by Jo Morg »

That simply won't work. Page blocks can't (afaik) be set dynamically from the content editor. These must be set statically on the chosen template and the editor will parse it once: when the template for the current page is set.
"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!
booka
Forum Members
Forum Members
Posts: 18
Joined: Fri Jan 17, 2014 8:58 am

Re: Number of {conent block} set in the page options???

Post by booka »

Jo Morg wrote:That simply won't work. Page blocks can't (afaik) be set dynamically from the content editor. These must be set statically on the chosen template and the editor will parse it once: when the template for the current page is set.
The main difficult is to set few {content block="id"} with id increment.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: Number of {conent block} set in the page options???

Post by Jo Morg »

How many are "few"?
There are a few approaches possible, two being pretty obvious to me:
  1. if you know the maximum number of blocks that will ever be used (assuming a reasonable number) then use:

    Code: Select all

    {content block="page 1" assign="one"}
    {content block="page 2" assign="two"}
    {* etc *}
     
    and then where you want them to show:

    Code: Select all

    {if isset($one)}
     <div class="mag-page-odd">
    {$one}
    </div>
    {if}
    {if isset($two)}
     <div class="mag-page-even">
    {$two}
    </div>
    {if}
    {* etc *}
  2. Create a number of templates with different number of blocks (worse for the designer/developer but better for the editor). Not a reasonable choice for a huge number of pages

However I don't see why would you even want to do this: the best way to publish articles is through other modules, like:
  • - News (core module);
  • - Blog;
  • - ListIt2;
In the case you need pagination and the module doesn't provide it you can resort to a smarty block plugin that divides the content in manageable pages (IIRC it is called precisely Pagination but you would have to search, I don't use it for ages). Other possibilities exist with javascrip and JQuery, for instance.
"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!
Post Reply

Return to “The Lounge”