Meta tags & Page titles in components

Discuss the development and implementation of Joomla! components here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
zigzag
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 249
Joined: Tue Sep 20, 2005 9:03 pm
Location: Elsewhere

Meta tags & Page titles in components

Post by zigzag » Mon Oct 17, 2005 2:29 am

Hi,

A lot of good components don't have page titles & meta tags, is there a way round this or a way to code them into the component files?
For example how would I go about doing this in the extcal component?

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Mon Oct 17, 2005 8:25 am

There's a way to code them in yourself :)

using the setPageTitle & appendMetaTag functions:

usage:

Code: Select all

<?php
$mainframe->setPageTitle('This is my title');

$mainframe->appendMetaTag('description', 'This content will be added to the description');
$mainframe->appendMetaTag('keywords', 'This will be added to the keywords');
?>
[edit: typo]
Last edited by Websmurf on Tue Oct 18, 2005 8:12 am, edited 1 time in total.
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

User avatar
zigzag
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 249
Joined: Tue Sep 20, 2005 9:03 pm
Location: Elsewhere

Re: Meta tags & Page titles in components

Post by zigzag » Mon Oct 17, 2005 10:37 am

Brilliant - thank you  :)

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Meta tags & Page titles in components

Post by DeanMarshall » Mon Oct 17, 2005 1:08 pm

Adam,

$mainframe->appendMetaTag('description', 'This content will be added to the description');

Is there a way to set a new description rather than appending.

Dean.
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Mon Oct 17, 2005 1:30 pm

i'm afraid there's no such thing currently that i'm aware of.
the only xxxMetaTag functions i've found add (meaning a double one) or append it.
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

User avatar
zigzag
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 249
Joined: Tue Sep 20, 2005 9:03 pm
Location: Elsewhere

Re: Meta tags & Page titles in components

Post by zigzag » Mon Oct 17, 2005 2:54 pm

Well they worked well on extcal and a few other components  :)
I had to change
$mainframe->addPageTitle('This is my title');
to
$mainframe->setPageTitle('This is my title');

gamesport
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 157
Joined: Mon Aug 22, 2005 1:39 am

Re: Meta tags & Page titles in components

Post by gamesport » Tue Oct 18, 2005 7:05 am

Websmurf wrote: There's a way to code them in yourself :)

using the setPageTitle & appendMetaTag functions:

usage:

Code: Select all

<?php
$mainframe->addPageTitle('This is my title');

$mainframe->appendMetaTag('description', 'This content will be added to the description');
$mainframe->appendMetaTag('keywords', 'This will be added to the keywords');
?>
is this setpagetitle/appendMetaTag functions only available in joomla, or is it available in mambo 4.5.2.3?

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Tue Oct 18, 2005 8:10 am

No, it's available in mambo as well as far as i know
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Tue Oct 18, 2005 8:12 am

zigzag wrote: Well they worked well on extcal and a few other components  :)
I had to change
$mainframe->addPageTitle('This is my title');
to
$mainframe->setPageTitle('This is my title');
That's indeed a small typo i've made.
the function is setPageTitle and NOT addPageTitle
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

gamesport
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 157
Joined: Mon Aug 22, 2005 1:39 am

Re: Meta tags & Page titles in components

Post by gamesport » Tue Oct 18, 2005 1:50 pm

Websmurf wrote: No, it's available in mambo as well as far as i know
pardon my ignorance here, but could you please give me a step by step on how and where to add those in mambo 4.5.2.3?
thanks

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Tue Oct 18, 2005 3:49 pm

in what component exactly?
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

gamesport
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 157
Joined: Mon Aug 22, 2005 1:39 am

Re: Meta tags & Page titles in components

Post by gamesport » Tue Oct 18, 2005 3:59 pm

i thought it would be the same for all components, anyways, its a custom component that a someone made for me.

but here are the files i have access to via ftp

/httpdocs/components/ com_ctmedia/ctmedia.html.php
/httpdocs/components/ com_ctmedia/ctmedia.php

question is, do i  add the meta tags / page title in any of those php files?
Last edited by gamesport on Tue Oct 18, 2005 4:21 pm, edited 1 time in total.

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Tue Oct 18, 2005 8:28 pm

Well, it's generally the same for each component.

you can add it in any of those files you like, there's only one small but, if you put $mainframe->setPage.. inside a function, you'll have to set $mainframe as a global object:

Code: Select all

<?php

//normal procedure, can be inserted anywhere
$mainframe->setPageTitle('This pagetitle will appear on this page');

//with a function:
function myFunction(){
  global $database, $option, $mainframe; //i've added $mainframe to the list here...

  $mainframe->setPageTitle('pagetitle');
}
?>
I normally use the last variant. It will be easier to locate a title if you're searching for it.
Hope this helps..
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

gamesport
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 157
Joined: Mon Aug 22, 2005 1:39 am

Re: Meta tags & Page titles in components

Post by gamesport » Wed Oct 19, 2005 5:08 pm

i added you code to the ..html.php thingy, and it still didnt work, do you have an msn or yahoo handle, so we can talk over messenger?

User avatar
Websmurf
Joomla! Hero
Joomla! Hero
Posts: 2230
Joined: Fri Aug 19, 2005 2:23 pm
Location: The Netherlands
Contact:

Re: Meta tags & Page titles in components

Post by Websmurf » Wed Oct 19, 2005 8:30 pm

Check my profile on this forum. MSN address is in there.
Adam van Dongen - Developer

- Blocklist, ODT Indexer, EasyFAQ, Easy Guestbook, Easy Gallery, YaNC & Redirect -
http://www.joomla-addons.org - http://www.bandhosting.nl

raspjam
Joomla! Apprentice
Joomla! Apprentice
Posts: 29
Joined: Tue Jan 22, 2008 8:04 pm

Re: Meta tags & Page titles in components

Post by raspjam » Thu Sep 22, 2011 7:25 pm

Hi, this solution will work with joomla 1.5?

mattcowan
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Nov 25, 2011 10:13 pm

Re: Meta tags & Page titles in components

Post by mattcowan » Fri Nov 25, 2011 10:17 pm

Came to this via search engine, not sure if this has the right information for J1.6+. I believe mainframe brings up an error, and you need to use JFactory to do what $mainframe used to do, like this:

$mainframe = JFactory::getApplication();

Could be wrong though, I am not an expert yet.


Locked

Return to “Components”