• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WriteNowDesign - Wordpress and Ecommerce Website Design

WordPress, Joomla, Ecommerce Website Design

  • Home
  • Prices/Packages
  • WordPress
  • Services
  • Portfolio
  • Blog
  • About
    • Testimonials
    • Locations
    • Online Payment
  • Contact
  • Show Search
Hide Search

Call 303-907-6133 Email

Screen Shot 2012-01-04 at 12.03.37 PM

Using Joomla’s Template and Layout Override

January 4, 2012 by Pat Fortino

Alternative Menu Items

Use Alternative Menu Items Layout Overrides to apply an override to an article linked directly to the menu.

For example, you copied

/components/com_content/articles/views/tmpl/article/default.php to

/templates/your-template/html/com_content/article/newdefault.php


And you copied

/components/com_content/articles/views/tmpl/article/default.xml to

/templates/your-template/html/com_content/article/newdefault.xml


The matching .xml file tells Joomla that the override is an Alternative Menu Item.

Once you create this, you will see the a new Menu Item Type. In the example below, I created a new Menu Item Type called New Default Single Article.

Joomla alternative menu item

To apply the Alternative Menu Item Type to an existing menu article link, open the article link and from the Menu Item Type field and click Select. Under the Articles category, you will see the new Menu Item Type you created.

To create a new article using the Alternative Menu Item Type, from the menu, click New and under the Articles category click the new Menu Item Type you created.

Joomla alternative menu item

Pages: Page 1 Page 2 Page 3

Comments are closed. If you have information to share, contact me here.

Previous Post: « Joomla Template Overrides and Layout Override Explained
Next Post: Joomla: Require Administrator Approval for User Registrations »

Reader Interactions

Comments

  1. Matt says

    December 15, 2012 at 9:47 am

    Hi there,
    I’ve tried this, and it works, but the new Menu Item Type just says “New Article”. and the link seems to be the same… what am I doing wrong?

    • Pat Fortino says

      December 16, 2012 at 7:09 am

      I think you have to modify the name in the xml file.

      • toufik says

        June 3, 2013 at 4:34 am

        hi, the layout override is missing and you can copy /components/com_content/articles/views/tmpl/article/default.php to

        /templates/your-template/html/com_content/article/default.php and you add this code:
        // Check for layout override
        $active = $app->getMenu()->getActive();
        if (isset($active->query[‘layout’])) {
        $this->setLayout($active->query[‘layout’]);
        } after line 14 or after $app.

        • Pat Fortino says

          June 3, 2013 at 4:58 am

          Not sure what you mean. That code is not in any templates in 2.0 or 3.0 but it works. I assume the check is coming from another file?

          • toufik says

            June 3, 2013 at 7:34 am

            hi,
            I think is better that the code muss be in core joomla in /com_content/articles/views/article/view.html.php in display function after check for error.

            I assume the check is coming from another file? yes from view.html.php

        • toufik says

          June 3, 2013 at 8:43 am

          the full code is:
          // Check for layout override joomla 2.5
          $active = $app->getMenu()->getActive();
          if (isset($active->query[‘layout’])) {
          $this->setLayout($active->query[‘layout’]);
          $this->display();
          return;
          }
          //
          // Check for layout override joomla 3
          $app = JFactory::getApplication();
          $active = $app->getMenu()->getActive();
          if (isset($active->query[‘layout’])) {
          $this->setLayout($active->query[‘layout’]);
          $this->display();
          return;
          }

Related

Primary Sidebar

Blog Categories

Call Today

Get a Free Quote

303-907-6133

Subscribe to News

News about WordPress, WooCommerce, & Technology

What’s New

  • WPForms Not Sending Notifications
  • Add Terms and Conditions WooCommerce
  • Fix WordPress AMP Validation Errors
  • Use the Classic Editor with Gutenberg Block Editor
  • Add a Message at Top or Bottom of WooCommerce Checkout Page
  • How to Link to a PDF in WordPress

Find Us On…

  • Facebook
  • LinkedIn
  • RSS

Call 303-907-6133 Email

© 2004–2022 · WriteNowDesign · Sitemap · Log in · Return to Top