Developer forum

Forum » Templates » template paragraph

template paragraph


Reply

hi

is there any way to controll wich templateParagraph is displayed in a page?

Without hardcoding it?

 

-jan


Replies

 
Reply

What do you mean? Hardcoding it where?

 
Reply

hi

 

say a page has three templateParagraphs, it would be usefull to controll witch templateParagraphs will be displayed in the page, say through a query parameter?

 

 

-jan

 
Reply

Sorry, I don't see the point here... The edit screen for a paragraph allows you to choose which template to use, if you want to use an other one than the one that is marked as default. What am I missing here to better understand your suggestion?

 
Reply

hi

 

we have a design that will diplay a 'next page' button if it has a subpage, we can solve this through the menu system and xstl, but it would be nice to do something like:

 

 

 

if (has another template paragraph) 

{

      display next button with url-display-page with next-template-paragraph 

}

 //<!--@If Defined(templateParagraph2)..?

 

just a thought..

 

Guess it can be solved another way using javascript

 

-jan

 
Reply
magenta wrote:

hi

 

we have a design that will diplay a 'next page' button if it has a subpage, we can solve this through the menu system and xstl, but it would be nice to do something like:

 

 

 

if (has another template paragraph) 

{

      display next button with url-display-page with next-template-paragraph 

}

 //<!--@If Defined(templateParagraph2)..?

 

just a thought..

 

Guess it can be solved another way using javascript

 

-jan

So when you have three paragraphs, you want this type of paging:

 

[Previous] [1] [2] [3] [Next]

 

No, Javascript is the way to go on this one.

 

Create a ParagraphSetup template that has this of code in the beginning:

 

<script language="Javascript" type="text/javascript">

    var Paragraphs = new Array();

 

    function record(ID){

        Paragraphs[Paragraphs.length] = ID;

    }

 

    function navigate(ÍD){

        for (i=0;i<Paragraphs.length;i++){

            document.getElementById(Paragraphs[i]).style.display = "none";

        }

        document.getElementById(ID).style.display = "block";

    }

</script>

 

In the template you use for the paragraph, you need wrap the HTML in something like this:

 

<script language="javascript" type="text/javascript">record("<!--@ParagraphID-->");</script>

<div id="<-@ParagraphID-->" style="display: none;">

 <!-- Paragraph content here -->

</div>

 

In the bottom of your ParagraphSetup template the then render the navigation:

<script language="javascript" type="text/javascript">

    for (i=0;i<Paragraphs.lenght;i++){

        document.write("<a href=\"javascript:void(0);\" onclick=\"navigate('" + Paragraphs[i] + "');\">" + (i+1) + "</a>")

    }

</script>

 
Reply

thanks!

 

exactly what I need, you guys make my job to easy :)

 

-jan

 
Reply

That's what we're here for:)

 

You must be logged in to post in the forum