Reputation: 43
i am developing job portal for that I am using joomla, i want to change browser tab title dynamically, for that iam using a page showjob and i passed job id through url to that page but joomla showing showjob as browser title but i don't want that , i need job title as browser tab title. for this what i did is
1.Created a menu item 'showjob'
2.Created a module 'showjob'
3.Assigned menu for 'showjob' module to 'showjob' menu item only
4.the 'showjob' module is a 'flexi custom php module' here i wrote databse connections and other stuff in php
5.the job id 'jid' passed through url from another module like www.example.com/jid=1;
6.in 'showjob' module i received it as $_GET['jid'] and retrieved the data as like $row['jtitle']; etc
7.Now i want that title as showjob page browser title
Upvotes: 0
Views: 744
Reputation: 1
So, I tried editing the title dynamically by creating a database with the page id's and the title name in a database and then calling the table and getting the queries. I successfully pulled it off. I Edited the head.php file using this code.
$jinput = JFactory::getApplication()->input;
$db = JFactory::getDbo();
$foo = $jinput->get('id');
$query1 = $db
->getQuery(true)
->select(array('*'))
->from($db->quoteName('#__page_title'))
->where($db->quoteName('page_id') . " = " . $db->quote($foo));
$db->setQuery($query1);
$results = $db->loadAssocList();
foreach ($results as $itemdata) {
$page_title = $itemdata["page_title"];
}
$app = JFactory::getApplication();
$this->setTitle( $this->getTitle() . ' - ' . $page_title);
Add this before this line of code $this->addHead(); Do let me know if this works for you!
Upvotes: 0
Reputation: 36829
Not sure I understand your Question 100%.
What if you try the following within the Flexi Custom PHP Module
$document = JFactory::getDocument();
$document->setTitle($row['jtitle']);
https://docs.joomla.org/JFactory/getDocument
Upvotes: 1