How do you remove some lines from the page head, render(head)?

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Wed Dec 06, 2017 11:20 pm

My theme layout file includes this line: <?php echo $this['template']->render('head'); ?>

There is a problem with the page <title> and I need to be able to strip out the title and add my own. I can do that php ordinarily but I don't know how to do that render(head).

How would I strip out the <title>...</title> line?

User avatar
effrit
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 174
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby effrit » Thu Dec 07, 2017 3:47 am

if you have JFactory::getDocument() just put one string after it.
if not - add this code

Code: Select all

$doc = JFactory::getDocument();
$doc->setTitle("myTitle");

bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

Re: How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Thu Dec 07, 2017 5:14 am

That gets me a little closer. What I really need to do is unset the title so that it is empty. How?

User avatar
effrit
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 174
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby effrit » Thu Dec 07, 2017 5:26 am

Code: Select all

$doc->setTitle("");

bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

Re: How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Thu Dec 07, 2017 5:46 am

Thank you, I tried that, however it leaves empty title tags:

<title></title>

and I need to get rid of this as well. Point me to the file where this is set and I can comment out the line.

User avatar
mbabker
Joomla! Hero
Joomla! Hero
Posts: 2023
Joined: Sun Feb 28, 2010 8:26 pm
Location: White Bear Lake, MN, USA
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby mbabker » Thu Dec 07, 2017 12:43 pm

You cannot completely remove the title tag without a core hack. You mentioned you want to add your own title, use the method already given to you and avoid a core hack.
Production Department Coordinator, Release Lead, CMS Maintainer, Framework Maintainer, Security Team Member, .org System Administrator

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281

bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

Re: How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Thu Dec 07, 2017 2:54 pm

The core hack is perfectly fine. I am doing this because of an extension causing a duplicate title problem confusing things. Please just point me to the core file.

User avatar
effrit
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 174
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby effrit » Thu Dec 07, 2017 3:01 pm

and why don't you fix the extension instead of hacking Joomla core?

bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

Re: How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Thu Dec 07, 2017 3:40 pm

5 minutes vs hours and cost

User avatar
mbabker
Joomla! Hero
Joomla! Hero
Posts: 2023
Joined: Sun Feb 28, 2010 8:26 pm
Location: White Bear Lake, MN, USA
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby mbabker » Fri Dec 08, 2017 7:12 pm

To be bluntly honest, if an extension can't be quickly fixed to resolve the duplicate title tag issue (it is probably arbitrarily just printing a title tag in the head instead of using the API), then you should reconsider your extension choice. The extension's logic is flawed and a core hack that has to be reapplied each month is just avoiding fixing the real issue.
Production Department Coordinator, Release Lead, CMS Maintainer, Framework Maintainer, Security Team Member, .org System Administrator

Manually updating Joomla? See https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281

bobmeetin
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Thu Sep 27, 2007 1:24 am

Re: How do you remove some lines from the page head, render(head)?

Postby bobmeetin » Sat Dec 09, 2017 3:22 pm

The question asked was how to the title from render(head). Why is it so difficult for people who know the answer to simply answer the question asked rather than force communication after communication, dragging this out, about why to or not to? Other people may want to know as well. No I'm not concerned whether it would be caught in an update or not - I can cover that.

Since no one seemed to be forthcoming with the one-line answer I went a different route. In the theme template I added an if/else clause disabling the core render(head) if the component is com_wordpress (the extension) and using a custom head I created. This gives me complete control of the title and meta description and removes the duplicate title entries.

The site will be transitioned to wordpress next year. The directive is to not license any commercial extensions in the interim, even if broken for any reason.

User avatar
effrit
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 174
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: How do you remove some lines from the page head, render(head)?

Postby effrit » Sat Dec 09, 2017 3:32 pm

the answer is simple - we don't want spread bad practice.
i use Joomla about 10 years and no one before ask about such nonsense.
if you have broken extension you must fix it instead of breaking Joomla.

Morissius
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Oct 31, 2017 7:41 pm

Re: How do you remove some lines from the page head, render(head)?

Postby Morissius » Sat Dec 09, 2017 3:47 pm

If all else fails you can use javaScript as a 'quickfix'. Don't neglect to properly fix it tough, but that is all on you.

Code: Select all

document.querySelector('title').innerText = "I can do changez";


Return to “Joomla! 3.x Coding”

Who is online

Users browsing this forum: No registered users and 5 guests