Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
8 posts Page 1 of 1
Hi folks,

i discovered CouchCMS some weeks ago and find it pretty awesome. Because i like to have nice and easy workflows, i made up a little setup to develop with CouchCMS using the building tool gulp. Because i am a fan of open source software, i would like to share it with you. I called it NoraGulp (because i develop it since i make a website for a person named Nora) and published it on github, you can check it out at https://github.com/JonnxW/nora-gulp.git.

I tried to make a complete documentation of the actual state, so it is easy to be used by others. If you try it out, i would appreciate some feedback on what can be done better and which features should be implemented. I am also open to get some of you to help me develop NoraGulp further.

Cheers and have a nice day,
Jonathan, a new but convinced user of CouchCMS
That looks awesome :)
Thank you, Jonathan.
Wow, Jonathan, this looks great!. Thanks very much!
Thank you! I hope it gets even more awesome and great over time. Hopefully it is usefull not only to me, but also other Couch developers.

I initially created it because i miss one feature: When creating different templates, i always have to make an own HTML markup. When something in the layout changes (e.g. i want to add padding to the nav bar), i have to change this in every template. Did i overlook a basic feature of CouchCMS or is there really no generic way to achieve this?
jwolff wrote: ... i have to change this in every template. Did i overlook a basic feature of CouchCMS or is there really no generic way to achieve this?


I see very little use of what you published on git. I am speaking for myself here.

Code differs from website to website and a lot of things need to be rewritten.
However, there is a nice way to minimize time - cms:smart_embed and cms:embed. Both tags are in documentation.
For example, all templates across my various project have almost identical content:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Index' clonable='0' gallery='0' dynamic_folders='0' order='0100' routable='0'>
    <cms:smart_embed 'template_editables' />
</cms:template><cms:ignore>
/*

    Index..
   
*/
</cms:ignore>
<cms:set my_debug='0' />
<cms:smart_embed debug=my_debug 'html_afore' />
<!DOCTYPE html>
<html lang="<cms:show k_lang />">
    <cms:smart_embed debug=my_debug 'html_headers' />
<body class="home-page">
    <cms:smart_embed debug=my_debug 'html_hero' />
    <cms:smart_embed debug=my_debug 'html_content' />
    <cms:smart_embed debug=my_debug 'html_footer' />
</body>
</html>
<?php COUCH::invoke(); ?>


Take a deep study of how cms:smart_embed works and it will be a timesaver. For example, if some code is the same across all templates (nav-bar) I could place it in a snippet /snippets/html_hero/default.html and it will be automatically picked by every template for every view.

Next, you should use template (snippet) inheritance: viewtopic.php?f=5&t=10984
If some template demands a slight change in navigation, then I would add a snippet /snippets/html_hero/my-template-name.html and put there only the changed part, while the rest will be inherited from that /default.html snippet.

There are many more tricks to reuse code. Functions cms:func will be next one I highly recommend to look through. viewtopic.php?f=8&t=11368&hilit=functions+cms%3Afunc&start=10#p30174

Good luck in your aspirations.
trendoman, thanks very much for your explanation of code reuse in Couch. As a beginner (I've only "couchified" one site) I was unaware of Couch's "smart embed" and "template inheritance" As with so many aspects of Couch, I'm extremely impressed.
Hello trendoman,
thank you very much for your reply, i really appreciate it. Unfortunately i cannot put as many time as i want in my web projects, so it took some time for me to go through your reply.

trendoman wrote: Take a deep study of how cms:smart_embed works and it will be a timesaver (...)
(...) Next, you should use template (snippet) inheritance:(...)
(...) Functions cms:func will be next one I highly recommend to look through. (...)


I looked through it and it actually is what i was trying to do. I think i will focus my tool on the optimization of the styling part. For now i am able to produce a fully responsive front end with a total amount of about 30kB of CSS code and just about 20 lines of JavaScript. If somebody is interested, i will give some feedback about the progress i achieve.

Sincerely, jwolff
Hi jwolff,
Please share with us anything you are working on, I am sure it will be either useful immediately or generate insights into more tips and tricks :)

It is always best to focus on what you can have time for.. Feel free to contact me if you need a helping hand with backend while you do the front-end stuff.
8 posts Page 1 of 1