0 users online. Create an account or sign in to join them.Users

Search

Hi,

I am looking for a best way to organize and then display sidebar blocks on multiple pages (if possible in custom sort order). Currently I am thinking of a section with all blocks available and then call the desired blocks on the pages. This is the tricky part where I got stuck and need your help.

A setup could look like this:

Sidebar Block Section

  • Block 1
  • Block 2
  • Block 3

Page 1 displays

  • Block 1
  • Block 2

Page 2 displays

  • Block 3
  • Block 1

and so on

You could create one section for your sidebar blocks content and another section for the relation between pages and sidebar contents using the pages field and mediathek extensions.

You could have a parameter for each block. Then on each Page, you would set the parameter for each block to ‘true’ or ‘visible’ or whatever.

Then, in your included utility XSLT, write the templates for each block, and have each template test its parameter to see if it should render.

Keep in mind, in XSLT you can’t operate on an undeclared param/variable. To overcome this, in your master.xsl, you’ll want to declare all the ‘block’ parameters on the top level (ie not within any templates), without giving them a value. Then, in your page template, give the block params a value if you want them to render.

Hope that makes sense. This is really just 1 of many possible solutions. I’m sure someone else has a totally different way. I don’t actually use this method; I process a secondary source xml file taht hold my layout for this sort of thing, but I think this will be more straightforward for you.

nm

klaftertief Looks like this is a very easy way to solve my problems. But currently I am trying to avoid 3rd party extensions until I am more familiar with symphony.

ashooner Thanks for the tips! I will look into this. Could you please give a code example for the following :

you’ll want to declare all the ‘block’ parameters on the top level

Thanks

Sure:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output encoding="UTF-8" indent="yes" method="xml" />
<!-- these would be set per Page-->
<xsl:param name='block1' value="'hidden'" />
<xsl:param name='block2' value="'visible'" />
<xsl:param name='block3' value="'visible'" />

<xsl:template match="/">
...
</xsl:template>
</xsl:stylesheet>

Then your block utility XSLT would look like:

<xsl:template name='block1'>
<xsl:if test="$block1 = 'visible'">
        <!-- block 1 xslt -->
</xsl:if>
</xsl:template> 

I will say that if you are comfortable using an extension, klaftertief’s solution is probably better, since it lets you manage the visibility of the blocks through the Symphony backend.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details