0
Welcome Guest! Login
0 items Join Now

How Can I Remove the <title> tag in the <head>, Gantry5?

    • Jim Dee's Avatar
    • Jim Dee
    • Sr. Rocketeer
    • Posts: 104
    • Thanks: 5
    • PHP, CSS, Gantry :-)

    How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • Working on a Gantry5 site...

      I have a page that's dynamic in that it takes a param, like /page?product=abc, /page?product=def, /page?product=ghi, etc.

      The problem is, I would like to script the <title> tag inside the <head> area myself because, as it is now, no matter what product I go to, the <title> of the page is always "Product Page". I can generate that <title> no problem by popping a script into the "Custom Content" area of Gantry5. BUT, the default <title> tag still remains. So, I'd need to know where in Gantry5 the <head> area gets generated so I can disable that <title> tag. I'm just not sure where that's at... anyone know?

      (BTW, I guess this is a core hack, which I'm not crazy about doing. Perhaps I should do a custom pllugin instead? Anyway.. would still like ot know where that <head> section gets generated.)
    • ______________________
      Jim Dee
      Principal, Array Web Development * 503-902-HTML
      * SERVICES: Joomla!, RocketTheme/Gantry, PHP, MySQL, CSS/HTML
      * PORTFOLIO: http://www.arraywebdevelopment.com
      * WRITING: https://medium.com/web-design-web-developer-magazine
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22449
    • Thanks: 2671
    • Web Developer

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • Jim Dee's Avatar
    • Jim Dee
    • Sr. Rocketeer
    • Posts: 104
    • Thanks: 5
    • PHP, CSS, Gantry :-)

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • Jim Dee's Avatar
    • Jim Dee
    • Sr. Rocketeer
    • Posts: 104
    • Thanks: 5
    • PHP, CSS, Gantry :-)

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • A bit of further detail... What I want to do is to run each page through some logic that may or may not change the <title> in the <head>. Basically, I was hoping to do something like this IF I need to change the <title> tag in the head...:
      $newTitle = 'New <head> <title>';
      $document = JFactory::getDocument();
      $document->setTitle($newTitle);

      I think the challenge here is that, if I use the "Custom Content" box in Gantry5 under "Head Properties" to get some code inserted (via Jumi, for example), the code above gets inserted too late in the Joomla game to take the action shown (changing the title). That is to say, the $document->setTitle has no effect at that point. I noticed this because, if I paste the code shown above at the top of the index.php file for my Gantry5 theme (using Notio, btw), it actually does work -- the title indeed changes.

      So... if I wanted to do a bit of a hackish solution, I could require my code at the top of the index.php file for my theme. That would definitely work. I mean, it's a hack, but it's one line of code, so I could live with it, I suppose. Just wondering if there is some other easy way to go about this, short of writing a formal plugin.
    • ______________________
      Jim Dee
      Principal, Array Web Development * 503-902-HTML
      * SERVICES: Joomla!, RocketTheme/Gantry, PHP, MySQL, CSS/HTML
      * PORTFOLIO: http://www.arraywebdevelopment.com
      * WRITING: https://medium.com/web-design-web-developer-magazine
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22449
    • Thanks: 2671
    • Web Developer

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • Jim Dee's Avatar
    • Jim Dee
    • Sr. Rocketeer
    • Posts: 104
    • Thanks: 5
    • PHP, CSS, Gantry :-)

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago
    • Yep, that looks like where it happens. :-) I guess my initial Gantry hack idea would work best, then. That's what I wound up doing.

      Not to promote Gantry hacks, but... Basically, what I did was insert a line atop my main theme file, like so:

      within: [root] / templates / [theme] / index.php
      added: require( 'path-to-my-script.php' );

      Then, inside path-to-my-script.php, I just added the conditional logic I needed. The pages in question had query string params like:

      &product=123

      So, I just had it scan for those params, and then, if found, added new titles / descriptions using the very same $document->setTitle($title); that Gantry / Joomla uses.

      Anyway, got it working. :-)
    • ______________________
      Jim Dee
      Principal, Array Web Development * 503-902-HTML
      * SERVICES: Joomla!, RocketTheme/Gantry, PHP, MySQL, CSS/HTML
      * PORTFOLIO: http://www.arraywebdevelopment.com
      * WRITING: https://medium.com/web-design-web-developer-magazine
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22449
    • Thanks: 2671
    • Web Developer

    Re: How Can I Remove the <title> tag in the <head>, Gantry5?

    Posted 1 year 10 months ago

Time to create page: 0.087 seconds