Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi,
I'm new to CMS and need some help...

I have two image types (banners) on my site

First banner for each cloned page showing all the time
Second global banner showing for a custom time period and replacing the first banner for this period.

How to disable first banner for a period when second banner is displaying?

Here is my code:

First banner:
<cms:pages masterpage='banner.php' folder='cal' >
<cms:embed 'ban/rev_index.php' />
</cms:pages>

Second banner:
<cms:pages masterpage='global_akcija.php' folder='cal' custom_field="date_of >
<cms:date format='Y-m-d H:i:s' />" show_future_entries='1'>
<cms:embed 'global_akcija_list.php'/>
</cms:pages>

Any idea?
Hi Drago,

There can be several different ways of handling this but I'll use the following technique as it has been already demonstrated in our Aurelius tutorial (http://www.couchcms.com/docs/tutorials/ ... -form.html) - namely the 'Buffering Output' technique.

With this technique we execute a set of statements (e.g. the second cms:pages block in your case that shows the global banner) however we do not output the results immediately. Rather we buffer it and wait for the results of other statements elsewhere in the template to decide on whether (or how) to display them.
Code: Select all
<cms:capture into='my_global_banner' >
    <cms:pages masterpage='global_akcija.php' folder='cal' custom_field="date_of > <cms:date format='Y-m-d H:i:s' />" show_future_entries='1'>
        <cms:embed 'global_akcija_list.php'/>
       
        <cms:set global_banner_available='1' 'global' />
    </cms:pages>
</cms:capture>

<cms:if global_banner_available >
    <cms:show my_global_banner />
<cms:else />
    <cms:pages masterpage='banner.php' folder='cal' >
        <cms:embed 'ban/rev_index.php' />
    </cms:pages>
</cms:if>

In the code above we buffer the global banner block in a global variable named 'my_global_banner'. In the same block we put a statement that flags that a banner has been found (global_banner_available='1').

Remember that if no suitable page is found, the cms:pages loop will not execute and in which case the flag we mentioned above will no be set.
We check for this in the next statements and if the 'global_banner_available' is set we show the global banner else we show the normal banners -
Code: Select all
<cms:if global_banner_available >
    <cms:show my_global_banner />
<cms:else />
    .. show the normal banner instead ..
</cms:if>

Hope this helps.
Thanks for the quick and effective response , I appreciate your work.
3 posts Page 1 of 1