meta data for this page

How to show the latest posts?

So you would like to add your latest blog posts to your website, this is very easy however you will need to customise this to match your theme.

Simply add the following line to your integration: $latest_posts = $this->Blogs->getLatestPost();

So the integration should look like this:

	Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
    // Menu items
    if ($this->Html->ifSet($logged_in)) {
       	$client_group = $this->Menus->grabClientGroup($contact->client_id);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus($client_group);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus('0');
    // Footer Links
    $footer_links = $this->Footer->getAllFooterLinks();
    $footer_categories = $this->Footer->getAllFooterCategories();
    // Multi-languages
    $lang = $this->Pages->getCurrentLang();
    $default_lang = $this->Pages->getAllLang()[0]->uri;
    // Latest blog posts
    $latest_posts = $this->Blogs->getLatestPost();

Then you need to use the following:

if (!empty($latest_posts)) {
  foreach($latest_posts as $key => $post ){
   <span class="position-relative mx-2 badge rounded-0 text-white" style="background: <?php echo $this->Html->safe($post->colour); ?>;padding: 5px;border-radius: 5px !important;text-transform: uppercase;"><?php echo $this->Html->safe($post->label_title[$lang]); ?></span>
<a class="text-white" href="//<?php echo $this->Html->safe($system_company->hostname . $this->Html->safe(WEBDIR) . 'blog/' . $post->uri); ?>">
  <?php echo $this->Html->safe($post->title[$lang]); ?>