Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
14 posts Page 2 of 2
I have added @snippets and @uploads keywords that are recognized and fixed to actual paths on server (be it custom-defined or CMS-default). I'll use it to automatically create empty snippets files to bootstrap a new template, if those do not exist yet. Updated code in public repository.
Is there a way to output couchcms code using <cms:write>

For example:
Code: Select all
<?php require_once( '../couch/cms.php' ); ?>
<cms:write "test.php" >
   <cms:template title="Dynamic Form Generation" clonable="1" >
      <cms:pages masterpage="test/index.php">
         <cms:show_repeatable "form_fields">
            <cms:editable name="<cms:show input_name />" label="<cms:show input_title />" type="<cms:show input_type />" order="<cms:show k_absolute_count />" />
         </cms:show_repeatable>
      </cms:pages>
   </cms:template>
</cms:write>
<?php COUCH::invoke(); ?>


Should output in the "test.php" file (as content):
Code: Select all
   <cms:template title="Dynamic Form Generation" clonable="1" >
      <cms:pages masterpage="test/index.php">
         <cms:show_repeatable "form_fields">
            <cms:editable name="<cms:show input_name />" label="<cms:show input_title />" type="<cms:show input_type />" order="<cms:show k_absolute_count />" />
         </cms:show_repeatable>
      </cms:pages>
   </cms:template>


Regards,
GXCPL (CTR)
Image
where innovation meets technology
This works for me —
Code: Select all
<cms:capture into='dynatext'>
    <%cms:if <cms:show name /> eq '1'>Yes<%cms:else/>No</%cms:if>
</cms:capture>

<cms:write 'test.txt'><cms:swap val='%cms:' with='cms:' text=dynatext /></cms:write>


I hope you get the idea which tags are executed and which are not. (Tag cms:swap is my custom tag for replacing substrings).
trendoman wrote: This works for me —
Code: Select all
<cms:capture into='dynatext'>
    <%cms:if <cms:show name /> eq '1'>Yes<%cms:else/>No</%cms:if>
</cms:capture>

<cms:write 'test.txt'><cms:swap val='%cms:' with='cms:' text=dynatext /></cms:write>


I hope you get the idea which tags are executed and which are not. (Tag cms:swap is my custom tag for replacing substrings).


@trendoman,

Thanks for the heads-up. This did help me. Though I didnt create a tag, but I directly used the str_replace() of php to achieve what was intended. Also, rather than replacing '%cms:' to 'cms:' I just replaced the '%' and it was done.

Regards,
GXCPL (CTR)
Image
where innovation meets technology
14 posts Page 2 of 2
cron