0
Welcome Guest! Login
0 items Join Now

SOLVED Class Outlines - custom current method

  • SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • Hi,

      I have a site with multiple styles that are loaded dynamically according to certain content conditions.

      In practice, I have modified Outlines.php and implemented a custom current method.

      Of course, this is far from an elegant solution since every time we have to update Gantry, we have to reapply the change.

      I have tried to implement a class override with a system plugin to load my Outlines, instead of the original Outlines. But, it is always already loaded.

      Is there any way to declare a custom Outlines class before Gantry's Outlines? Any way to extend the current method of the Outlines class?

      Thanks in advance,
      Anibal
    • Best Regards,
      Anibal Sanchez
      ____________________________________

      Extly.com - Extensions
  • Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • PD: I think it could be solved with a custom router, but I'm looking for a way to solve it at Gantry level.
    • Best Regards,
      Anibal Sanchez
      ____________________________________

      Extly.com - Extensions
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13484
    • Web Designer/Developer

    Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • Please note that by answering your own post you take yourself out of the MODS "unanswered posts" queue and therefore might have to wait longer for a response - it's better to edit your original post so this does not happen.

      I really don't know what you are trying to do but changing core Gantry files is the wrong thing to be doing.

      If you want to style elements based upon the outline being used then you should just qualify your CSS selectors in a custom CSS file as there is a class on the body tag that states which outline is being used ("outline-999"). Also there is a class on the body tag that tells you what menu item is being used too.

      I don't understand what these "conditional" styling could be other than the above?

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
  • Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • Hi,

      I know core classes shouldn't be modified.

      Let me introduce the use case:
      • A news site have several layouts defined based on a Gantry template
      • Users only know to load articles
      • Template must be able to choose dynamically the right layout according to the set of articles to show

      For example, today, we have a breaking news, so the associated layout have to be shown based on the available content.

      Outlines class can do it selecting a different "current" layout.... but it seems impossible to implement a "content-aware" routine.

      If there is no alternative, I think I will try to implement a custom router.

      Regards,
    • Best Regards,
      Anibal Sanchez
      ____________________________________

      Extly.com - Extensions
    • MrT's Avatar
    • MrT
    • Preeminent Rocketeer
    • Posts: 101084
    • Thanks: 13484
    • Web Designer/Developer

    Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • To be honest I don't really understand the scenario you are asking about so I've asked our DEVS to comment here... They should add a reply shortly, please be patient though, they are very busy...

      Regards, Mark.
    • Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
    • Matias Griese's Avatar
    • Matias Griese
    • Sr. Rocketeer
    • Posts: 249
    • Thanks: 104
    • Lead Developer

    Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • There's architecture in place to support custom outline assignments, but its kind of hardcoded in Joomla as its using older version of the code. Basically the newer method allows us to write code to assign outlines to components, categories or really anything you could imagine -- and have options to configure it in admin. But as I said, I need to update some code to make it to work.

      In the mean time you can still change assignments from a custom system plugin. Just hook into onAfterRoute event by inserting following code:
          public function onAfterRouteSite()
          {
              $app = JFactory::getApplication();
              if (!$app->isSite()) 
              {
                  return;
              }
              
              // Make sure Gantry has been loaded (and theme is active).
              if (!class_exists('Gantry\Framework\Gantry'))
              {
                  return;
              }
              
              // TODO: Add logic to set the custom outline. 
              // NOTE: Just remember not to set outline if you want to use regular template style assignments.
              $outline = null;
              if (1) 
              {
                  $outline = 'default';
              }
              elseif (0)
              {
                  $outline = 'foobar';
              }
      
              // If custom outline is set, use it!
              if (isset($outline)) 
              {
                  $gantry = Gantry\Framework\Gantry::instance();
                  $theme = $gantry['theme'];
                  $theme->setLayout($outline);
              }
          }

      Just make sure your plugin comes AFTER System - Gantry 5 plugin as otherwise this plugin would do nothing.

      No core changes needed to Gantry!
    • Last Edit: 8 years 6 months ago by Matias Griese.
    • The following users have thanked you: MrT

    • Gantry 5, enjoy!
    • Matias Griese's Avatar
    • Matias Griese
    • Sr. Rocketeer
    • Posts: 249
    • Thanks: 104
    • Lead Developer

    Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • You can also do it opposite way and call
      $app->setTemplate($template, $styleParams);

      before Gantry plugin gets run.

      There you need to load $styleParams from the database, so its a bit more complicated way, but the good thing with that method is that it works also without Gantry.
    • Last Edit: 8 years 6 months ago by Matias Griese.
    • The following users have thanked you: MrT

    • Gantry 5, enjoy!
  • Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • Excellent, that's what I was looking for!
    • Best Regards,
      Anibal Sanchez
      ____________________________________

      Extly.com - Extensions
    • Matias Griese's Avatar
    • Matias Griese
    • Sr. Rocketeer
    • Posts: 249
    • Thanks: 104
    • Lead Developer

    Re: SOLVED Class Outlines - custom current method

    Posted 8 years 6 months ago
    • If you have very, very technical questions to ask, please use GitHub as I'm not really following the forums.
    • Gantry 5, enjoy!

Time to create page: 0.055 seconds