Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have a text marquee (scrolling text) on every page in a web site. It shows a series of text items that we'd like to be editable in the CMS (as a repeating region, so that however many items of text we want will show up one after the other in the marquee).

Facts of the case:

1. The code that displays the scrolling text is contained inside a regular PHP server-side include. (So it can be easily reused on dozens of web pages.) The repeating region that contains the marquee's scrolling text items would therefore have to be inside that SSI as well. The name of this include is "header.php".

2. But, since the web pages that will call the SSI already invoke Couch themselves, I cannot put a Couch invoke inside the SSI itself. (As I've seen elsewhere, this seems to lead to a double-Couch-invoke and screws up other things.)

3. The above fact means that I can't put my <cms:editable /> tags inside the SSI, because without invoking Couch inside the SSI file itself, the Couch admin panel won't process and "see" what's in the SSI file.

4. Therefore, I guess I should make a separate PHP file that lets me define the marquee text items as global variables, and then "show" those pre-defined global variables inside a repeating region in the SSI file.

I've tried following the "Tying things up" page in the documentation, but this isn't working. I'm doing something or some things very wrong. Here's my code:

in a php file called "marquee_globals.php", I've got this:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template name='marquee_globals' title='Marquee Contents' executable='0'>
<cms:repeatable name='marquee_events' >
    <cms:editable name='marquee_event_datetime' label="Date and Time" type='text' />
    <cms:editable name='marquee_event_description' label="Event Name" type='nicedit' />
    <cms:editable name='marquee_event_venue' label="Event Location" type='nicedit' />
</cms:template>
<?php COUCH::invoke(); ?>


Inside my header.php server-side include, I have this code:

Code: Select all
<cms:pages masterpage='marquee_globals.php' >
    <cms:set g_marquee_event_datetime = marquee_event_datetime 'global' />
    <cms:set g_marquee_event_description = marquee_event_description 'global' />
    <cms:set g_marquee_event_venue = marquee_event_venue 'global' />
</cms:pages>

<cms:show_repeatable 'marquee_events' >
    <cms:excerptHTML count='150' ignore='br'>
    <span class="bold">
    <cms:show g_marquee_event_datetime />: </span><cms:show g_marquee_event_description />, <cms:show g_marquee_event_venue />.
    </cms:excerptHTML>
</cms:show_repeatable>


The Couch code is being processed because no Couch code is present in the source of the outputted web page. But nothing is being returned, even though I've successfully entered text content for three rows of the editable fields.

I'm sure some will see the code I posted above and laugh out loud. And I'll understand. But. ... Any suggestions?
First of all your template definition lacks a closing <cms:repeatable> tag:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template name='marquee_globals' title='Marquee Contents' executable='0'>
<cms:repeatable name='marquee_events' >
    <cms:editable name='marquee_event_datetime' label="Date and Time" type='text' />
    <cms:editable name='marquee_event_description' label="Event Name" type='nicedit' />
    <cms:editable name='marquee_event_venue' label="Event Location" type='nicedit' />
</cms:repeatable>
</cms:template>
<?php COUCH::invoke(); ?>



Next, what you're trying to do in the header.php file won't work:

Code: Select all
<cms:pages masterpage='marquee_globals.php' >
    <cms:set g_marquee_event_datetime = marquee_event_datetime 'global' />
    <cms:set g_marquee_event_description = marquee_event_description 'global' />
    <cms:set g_marquee_event_venue = marquee_event_venue 'global' />
</cms:pages>


As those couch variables are only available inside the show_repeatable region (which you haven't invoked).

Please try the below on the header.php page and let me know if it works. (You can remove the "global" definitions you were trying to set).

You can't globally define those variables in the template, if you could access them - then you would be able to show them directly, as we do below.

Code: Select all
<cms:pages masterpage='marquee_globals.php' >
   <cms:show_repeatable 'marquee_events' >
      <cms:excerptHTML count='150' ignore='br'>
      <span class="bold">
      <cms:show marquee_event_datetime />: </span><cms:show marquee_event_description />, <cms:show marquee_event_venue />.
      </cms:excerptHTML>
   </cms:show_repeatable>
</cms:pages>
Image
Bartonsweb!

You did it!


The code you provided worked perfectly. Thank you a hundred times over for sparing me days of clueless investigation and trial and error.
3 posts Page 1 of 1
cron