Different CMS syntax for similar queries

  • Started
  • Last post
  • 4 Responses
  • ETM

    After looking at the 'WordPress beginner' thread and the WP syntax, I thought it might interesting to post what it would take in other CMS's to roughly replicate the same functionality from various examples.

    To start, using the example from the mentioned thread:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if ( in_category( '4' ) ) : ?>
    <article class="post">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <p class="bodyDate"><?php echo get_the_date(); ?></p>
    <p><?php echo get_the_excerpt(); ?><br></p>
    </article>
    <?php endif; ?>
    <?php endwhile; else : echo '<p>No content found</p>';
    endif;
    ?>

  • ETM0

    An example from ExpressionEngine:

    {exp:channel:entries channel="content" category="4" status="post" sort="asc"}

    {if no_results} <p>No content found</p> {/if}

    <article class="post">
    <a href="{permalink=enewsletter/article}">{title}</a>
    <p class="bodyDate">{body_date}</p>
    <p>{excerpt}</p>
    </article>

    {/exp:channel:entries}

    • cleaner but same kinda.BabySnakes
    • Just comparing what it takes to get the same results in other CMS implementations. What's similar and different.ETM
  • estetic0

    CraftCMS

    {% for entry in craft.entries.section('news').re... %}
    <article class="post">
    <a href="{{ entry.url }}">{{ entry.title }}</a>
    <p class="bodyDate">{{ entry.postDate }}</p>
    <p>{{ entry.summary }}</p>
    </article>
    {% endfor %}

    • I like Craft as an overall product, but don't love Twig for templating.ETM
  • monNom0

    That WP syntax is ugly. You could tidy that up a lot.

  • BabySnakes0

    I like the cleanness though sometime it feels like it can limit your ability to do special mods. Can you still use php methods to modify data in these templates or does it have to all be processed before hand?

    • EE can run PHP within templates with some fiddling - craft relies on plugins and twig filters...estetic
    • Personally the division between presentation and logic makes sense. Not a huge fan of WP, it does some things really well and is a mess for othersestetic