One of the features I created was a masonry style view (https://www.testingthis.website/trips) with no javascript or css edits – just some simple template overrides.

The tutorial below is for creating a simpler version of that view using tags instead of custom fields. A custom fields version will follow.

Setup

  • Create a single category called Holiday
  • Create the tags you need to filter the content eg Beach, Nature, City, Historic
  • Create multiple articles in the Holiday category
    • Add Tags to each article
    • Add Readmore to each article
  • Create a menu item of type Articles->Category Blog
  • Edit the Holiday category and add all the tags

Template Override 1

  • Create overrides for Layouts->joomla->content
  • Create a new file called filters.php in the folder /templates/template_name/html/layouts/joomla/content
  • Paste the code below into that file and save
    <?php defined('_JEXEC') or die; ?>
    <?php if (!empty($displayData)) : ?> <?php foreach ($displayData as $i => $tag) : ?> <input type="checkbox" class="btn-check" name="CheckBox" id="<?php echo $tag->alias; ?>" value="<?php echo $tag->alias; ?>"> <label class="btn btn-outline-primary btn-sm" for="<?php echo $tag->alias; ?>"><?php echo $tag->title; ?></label> <?php endforeach; ?>
    <?php endif; ?> 

Template Override 2

  • Create overrides for Components->com_content->category
  • Open the override for /templates/template_name/html/com_content/category/blog.php
  • Insert the code below before line 36
    $tags = $this->category->tags->itemTags;
    $filter = implode( ',', array_map( fn(object $tag): string => '[value="' . $tag->alias . '"]:checked ~ .blog-items .blog-item:not([data-category~="' . $tag->alias . '"])', ($this->category?->tags?->itemTags ?? []) ?: [] ) );
    /** @var JoomlaCMSWebAssetWebAssetManager $wa */
    $wa = Factory::getApplication()->getDocument()->getWebAssetManager();
    $wa->addInlineStyle($filter . '{display: none; opacity: none;}'); 
  • On new line 63 replace joomla.content.tags with joomla.content.filters

    image-20221018133544281

  • Around line 105 delete the highlighted code below

    image-20221018134051383

  • Save & Close the file.

Template Override 3

  • Open the override for /templates/template_name/html/com_content/category/blog_item.php
  • Before line 35 insert the following code
    <div class="com-content-category-blog__item blog-item" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting" data-category=" <?php if ($params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?> <?php foreach ($this->item->tags->itemTags as $tag) { echo $tag->alias . ' '; }; ?> <?php endif; ?> ">
    
  • At the very end of the file insert the following code
    </div>
    

  • Google Ad Manager Launches Programmatic Email Ads
    Google Ad Manager has quietly published documentation for a beta version of an advertising tag for email newsletters.
    Email ads are cookie-proof. They do not depend on third-party tracking cookies for targeting. The end of tracking cookies in web browsers (as soon as 2025) has publishers and advertisers searching for new channels.
    Email’s targeting capability could be the primary reason GAM is adding support.
  • eCommerce website solutions that drives salesccording to HubSpot, 80% of online shoppers stop doing business with a company because of poor customer experience. When all of your competition is also selling online, the shopping experience you offer your customers will be a critical differentiator.
  • The Best WordPress Hosting Solution in AustraliaEach of our WordPress hosting solutions are fine-tuned, blazing fast and are ready for you! Starting a WordPress website has never been easier with our free 1-click WordPress installation, enterprise-grade security and an assortment of tutorials and helpful guides to get you started, all backed by our 99.9% uptime guarantee.
  • Multilingual WordPress Sites to Reach a Global AudienceIf you are seeking to broaden the reach of your WordPress site to target an international audience, the following discussion on the leading multilingual WordPress plugins will be of interest. The plugins to be covered include WPML, Polylang, Weglot, TranslatePress, and GTranslate.
  • How to Reset Forgotten Root Password in RHEL SystemsThis article will guide you through simple steps to reset forgotten root password in RHEL-based Linux distributions such as Fedora, CentOS Stream, Rocky and Alma Linux.
  • VMware NSX Multi-tenancy; True Tenant Isolation?What is VMware NSX multi-tenancy? Historically multi-tenancy in VMware NSX was a Tier-0 gateway, otherwise known as the provider router, with one or many child Tier-1 gateways.
  • How To Install Elasticsearch On RunCloudElasticsearch is a powerful, open-source search engine and analytics platform for storing, searching, and analyzing large volumes of data in real time.
  • WooCommerce vs BigCommerce: What’s the Best Choice?If you’re starting an online store, one of the first decisions you’ll need to make is the eCommerce platform you’re going to use.
  • Top WordPress Backup Plugins to Safeguard Your Website Data and Ensure RecoveryGiven the abundance of backup plugins available, the process of selecting the most suitable one can be daunting. This article aims to examine prominent WordPress backup plugins such as UpdraftPlus, BackupBuddy, BlogVault, among others.

Similar Posts