I am trying to list a few games, each, on individual pages. While a game page is opened into a new window the head title of page (< title>) is set to games page header (< h1> My Game). Also to list all game types I am using quick tabs.
From 12 types of games only at 2 of them the title is settled correctly and my problem is that I don't know from where it comes. I have tried to var_dump() all the headers and all of them are returning the same thing "Game" not the title/heading from db.
Where should I look or what would be the next step ?
$metaTitle = $page['content']['metatags']['global']['title']['#attached']['metatag_set_preprocess_variable'][0][2];
$metaTitle = str_replace(' | SuperCasino.com', '', $metaTitle);
Where should I look or what would be the next step ?
Here is my preprocess page code
function desktop_preprocess_page(&$vars, $hook) {
if (isset($vars['node_title'])) {
$vars['title'] = $vars['node_title'];
}
// Adding a class to #page in wireframe mode
if (theme_get_setting('wireframe_mode')) {
$vars['classes_array'][] = 'wireframe-mode';
}
// Adding classes wether #navigation is here or not
if (!empty($vars['main_menu']) or !empty($vars['sub_menu'])) {
$vars['classes_array'][] = 'with-navigation';
}
if (!empty($vars['secondary_menu'])) {
$vars['classes_array'][] = 'with-subnav';
}
// Page template suggestions based off of content types
if (isset($vars['theme_hook_suggestions']['node'])) {
$vars['theme_hook_suggestions'][] = 'page__type__'. $vars['node']->type;
$vars['theme_hook_suggestions'][] = "page__node__" . $vars['node']->nid;
}
// Add first/last classes to node listings about to be rendered.
if (isset($vars['page']['content']['system_main']['nodes'])) {
// All nids about to be loaded (without the #sorted attribute).
$nids = element_children($vars['page']['content']['system_main']['nodes']);
// Only add first/last classes if there is more than 1 node being rendered.
if (count($nids) > 1) {
$first_nid = reset($nids);
$last_nid = end($nids);
$first_node = $vars['page']['content']['system_main']['nodes'][$first_nid]['#node'];
$first_node->classes_array = array('first');
$last_node = $vars['page']['content']['system_main']['nodes'][$last_nid]['#node'];
$last_node->classes_array = array('last');
}
}
//var_dump($vars['theme_hook_suggestions']);die();
// Page template suggestions based off URL alias
if (module_exists('path')) {
//$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
$alias = request_path();
if ($alias != $_GET['q']) {
//echo'here';die;
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '__' . str_replace('-','_',$path_part);
$vars['theme_hook_suggestions'][] = $template_filename;
//var_dump($template_filename);
}
}
}
You can use drupal_set_title(YOUR_TITLE) for the different pages.
drupal_set_title($title = NULL, $output = CHECK_PLAIN)
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_set_title/7
From the theme level, you can use this code in your template.php:
function MYTHEMENAME_preprocess_page(&$vars, $hook) {
$vars['title'] = $custom_title';
$vars['head_title'] = $custom_title;
}
For Drupal 7 its is :
$vars['site_name']
Related
Am displaying list haviing
Date
News Heading
Short Descrption
The list is spread to around 100 pages, having 20 news in each page
Issue is: This is working absolute fine in php 7.3, 7.4 in joomla 3.10 where on clicking url - list is shown spread over multiple pages having sort by date wise as first criteria, latest date of publishing is coming
But when same used on php 8.0.x - its showing incorrectly, where on clicking URL - last page of list having page number 100 is shown first. Now when i add on limitstart=0 in url then its showing correctly as the first page.
Now when i change from descending to ascending - its bringing the content on last page and its opening, but page number is 100 again
Seems like URL when opened is directly taking to last page of news item as published (although no limitstart is mentioned in it), which is incorrect as ideally should open in descending order and open the page having latest one
Below is code of views/list/tmpl/default.php
if(count($this->items) >0){
//$i=1;
foreach($this->items as $newslist)
{
$date = JFactory::getDate($newslist->n_date);
$list .='<h3><strong>'.$newslist->v_heading.'</strong></h3>
<p>'. $date->format('F j, Y').'</p>
<p>'.substr($newslist->v_short_description,0,100).'</p>
<p><i>Know More on:- </i><b><i>'.$newslist->v_heading.'</i></b></p><hr/><br>';
//$i=$i+1;
}
}else{
JError::raiseError(404, "Message");
}
<?php echo $list?>
and for models/list.php this is the function
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query
->select(
$this->getState(
'list.select', 'DISTINCT a.*'
)
);
$query->from('`#__news` AS a');
if (!JFactory::getUser()->authorise('core.edit', 'com_news'))
{
$query->where('a.state = 1');
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->Quote('%' . $db->escape($search, true) . '%');
$query->where('( a.n_heading LIKE ' . $search . ' )');
}
}
/*
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol && $orderDirn)
{
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
*/ //Order by date
$query->order ('a.n_date DESC');
$query->order ('a.id DESC');
return $query;
}
This is the code for views/list/view.html.php
public function display($tpl = null)
{
$app = JFactory::getApplication();
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->params = $app->getParams('com_news');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors));
}
$this->_prepareDocument();
parent::display($tpl);
}
Unsure how to achieve in and why its not working in php 8.0 where url should open the 1st page and not last page
I'm running a social network and right now my search.php shows results for people, and tags. How can I add an RSS Feed? I own a blog and I wanted to add my RSS Feed to the search so whenever someone searches for a topic it will show up on the search page.
Here's the search.php code:
$feed = new feed();
$feed->db = $db;
$feed->url = $CONF['url'];
if(isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
$verify = $loggedIn->verify();
if($verify['username']) {
$feed->user = $verify;
$feed->username = $verify['username'];
$feed->id = $verify['idu'];
if(isset($_GET['tag'])) {
$skin = new skin('shared/top'); $top = '';
$TMPL['theme_url'] = $CONF['theme_url'];
$TMPL['private_message'] = $verify['privacy'];
$TMPL['avatar'] = $verify['image'];
$TMPL['url'] = $CONF['url'];
$top = $skin->make();
}
}
}
$feed->per_page = $settings['perpage'];
$feed->time = $settings['time'];
$feed->censor = $settings['censor'];
$feed->smiles = $settings['smiles'];
$feed->c_per_page = $settings['cperpage'];
$feed->c_start = 0;
$feed->l_per_post = $settings['lperpost'];
$TMPL_old = $TMPL; $TMPL = array();
$skin = new skin('shared/rows'); $rows = '';
if(empty($_GET['filter'])) {
$_GET['filter'] = '';
}
// Allowed types
if(isset($_GET['tag'])) {
// If the $_GET keyword is empty [hashtag]
if($_GET['tag'] == '') {
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$hashtags = $feed->getHashtags(0, $settings['qperpage'], $_GET['tag'], null);
$TMPL['messages'] = $hashtags[0];
} else {
// If the $_GET keyword is empty [user]
if($_GET['q'] == '') {
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$TMPL['messages'] = $feed->getSearch(0, $settings['qperpage'], $_GET['q'], $_GET['filter']);
}
$rows = $skin->make();
$skin = new skin('search/sidebar'); $sidebar = '';
if(isset($_GET['tag'])) {
$TMPL['trending'] = $feed->sidebarTrending($_GET['tag'], 10);
} else {
$TMPL['genre'] = $feed->sidebarGender($_GET['filter'], $_GET['q']);
}
$TMPL['ad'] = generateAd($settings['ad6']);
$sidebar = $skin->make();
$TMPL = $TMPL_old; unset($TMPL_old);
$TMPL['top'] = $top;
$TMPL['rows'] = $rows;
$TMPL['sidebar'] = $sidebar;
if(isset($_GET['logout']) == 1) {
$loggedIn->logOut();
header("Location: ".$CONF['url']."/index.php?a=welcome");
}
$TMPL['url'] = $CONF['url'];
if(isset($_GET['tag'])) {
$TMPL['title'] = '#'.$_GET['tag'].' - '.$settings['title'];
} else {
$TMPL['title'] = $LNG['title_search'].' - '.$_GET['q'].' - '.$settings['title'];
}
$skin = new skin('shared/timeline_x');
return $skin->make();
Please help :)
Try this example
<?php
$articles = $pages->find('blog')->children()->visible()->flip()->limit(10);
snippet('feed', array(
'link' => url('blog'),
'items' => $articles,
'descriptionField' => 'text',
'descriptionLength' => 300
));
?>
link:
This is the main link in our feed, which takes the visitor back to our site. In this case we want them to get back to our blog, so we build an url to our blog with the url() helper function.
items:
As items for our feed, we pass the set of $articles we found in the first line. The feed snippet will automatically take care of getting the right info out of those $articles (like title, url, etc.)
descriptionField:
If you want to show a description for each item in your feed, you need to specify a field, which is available in any item and should be used for the description.
descriptionLength:
This is maximum number of characters the description will have. An excerpt is automatically generated by the feed snippet.
Here is my current component setup. I have a very dynamic page generation component that syncs with data from a external API to create pages for products without extra data entry.
Right now it works at a simple button click to populate all and update any changes, or just update individual fields. What this leads to is the generation of static "pages" from the api in joomla, and the ability to update it from the api.
The problem comes into the fact that this is used as the "home" menu item so the component itself takes the root directory. What I need is each "page" to take a sub menu of home automatically, though just setting the main menu item as home does not seem to work, it leads to the JRoute class getting confused and using component/ , everything I have read so far takes the assumption it is not the default menu item so I am losing home making it fully automatic.
So my question is, is there a function class to create menu items from components in joomla? adding another row to the joomla menu table for each page while i update them "should" solve the problem, I know I can try to figure out how joomla adds them to the database on my own, but I would prefer to use a joomla class/function if at all possible, any ideas?
here is my current router.php, works fine for directly linking to the page but not when using JRoute. There is some uneeded parts to this as I have been doing some extensive testing though.
<?php
defined('_JEXEC') or die;
function GoFormsBuildRoute($query){
$segments = array();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$params = JComponentHelper::getParams('com_goforms');
$db = JFactory::getDBO();
if (empty($query['Itemid'])) {
$menuItem = $menu->getActive();
$menuItemGiven = false;
}
else {
$menuItem = $menu->getItem($query['Itemid']);
$menuItemGiven = true;
}
//print_r($menuItem);
if(isset($query['option'])){
unset($query['option']);
}
if(isset($query['view'])){
$view = $query['view'];
}else{
return $segments;
}
unset($query['view']);
if(isset($query['id'])){
if ($menuItemGiven && isset($menuItem->query['id'])) {
$mCatid = $menuItem->query['id'];
} else {
$mCatid = 0;
}
//echo 'hi';
if(strpos($query['id'], ':') === false) {
$db = JFactory::getDbo();
$aquery = $db->setQuery($db->getQuery(true)
->select('alias')
->from('#__goforms_list')
->where('id='.(int)$query['id'])
);
$alias = $db->loadResult();
$query['id'] = $alias;
}
$segments[] = $query['id'];
unset($query['id']);
}
print_r($segments);
return $segments;
}
function GoFormsParseRoute($segments){
$vars = array();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
$params = JComponentHelper::getParams('com_goforms');
$db = JFactory::getDBO();
print_r($item);
$count = count($segments);
if($count == 1){
if(isset($segments[0])){
$vars['view'] = 'region';
$alias = str_replace(':','-',$segments[0]);
//print_r($alias);
//echo '<br>';
$query = 'SELECT alias, id FROM #__goforms_list WHERE alias = "'.$alias.'"';
$db->setQuery($query);
$page = $db->loadObject();
if($page){
$vars['view'] = 'region';
$vars['id'] = (int)$page->id;
return $vars;
}else{
$vars['view'] = 'goforms';
}
}else{
$vars['view'] = 'goforms';
}
}
return $vars;
}
?>
in review:
Joomla 2.5
component is at root menu item of site (home)
items from component need to fall under the first level of menu after home
links work, however JRoute class in joomla does not properly make the link.
I have a news article with internal links. In the RTE I see links like
http://www.yourdomain.com/?id=3
in the html text mode. The problem is that this link also appears on the frontend. RealURL should convert this link to something like
http://www.yourdomain.com/products/
The content of RTE is currently parsed like this
$parseObj = t3lib_div::makeInstance('t3lib_parsehtml_proc');
$txt = $parseObj->TS_links_rte($result['bodytext']);
$txt = $parseObj->TS_transform_rte($txt);
I read that I should use something like this
$pObj = t3lib_div::makeInstance('tslib_pibase');
$txt = $pObj->pi_RTEcssText($result['bodytext']);
but I don't know how can I access this function. I get
Fatal error: Call to a member function parseFunc() on a non-object in /home/myuser/www/home/typo3/sysext/cms/tslib/class.tslib_pibase.php on line 1384
What is the right way doing this? How can I access the function pi_RTEcssText? Do I have to use a class? Are there other ways doing it without a class?
EDIT:
I created a new template with TemplaVoila and defined lib.newscontent as TS object path.
TS Main Template
includeLibs.user_news = fileadmin/templates/php_scripts/news/class.news.php
lib.newscontent = USER_INT
lib.newscontent {
userFunc = user_news->main
userFunc.bodytext.parseFunc < lib.parseFunc_RTE
}
class.news.php
<?
class user_news {
var $cObj;
private $conf;
function main($content,$conf) {
$this->conf = $conf;
$this->setPreferences();
$content .= $this->aktuelleNews();
return $content;
}
private function aktuelleNews() {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*', // SELECT ...
'tt_news', // FROM ...
'pid=22 AND deleted=0 AND hidden=0', // WHERE...
'', // GROUP BY...
'datetime DESC' // ORDER BY...
);
$i = 1;
$out_list = '<ul id="news">';
while ($data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$date = date("d.m.Y",$data['datetime']);
$out_list .= '<li>'.$date.': '.$data['title'].'</li>';
$out_detail.= $this->outputnewsdetail($data,$i);
$i++;
}
$out_list .= '</ul>';
return $out_list . $out_detail;
}
private function outputnewsdetail($result,$count){
$this->cObj->start($result, 'tt_news');
$bodytext = $this->cObj->stdWrap($result['bodytext'], $this->conf['bodytext']);
$bodytext = $this->cObj->parseFunc($bodytext,$GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);
return $bodytext;
}
private function setPreferences() {
}
}
?>
localconf.php
include(PATH_site.'fileadmin/templates/php_scripts/news/class.news.php');
Remaining question
Why does the rendering part in the TS Main Template doesn't work? I used
$this->cObj->parseFunc($bodytext,$GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);
to get my result.
I would prefer:
$txt = $this->cObj->stdWrap($result['bodytext'], $this->conf['bodytext.']);
You need in your main method: $this->conf = $conf;
In your TypoScript add the parseFunc to bodytext:
plugin.tx_yourplugin_pi1 {
bodytext.parseFunc < lib.parseFunc_RTE
}
The main idea is to use the usual parseFunc which is used by content elements. So you have the same rendering. Another benefit is, that your application is more flexible.
Just as a side note. It is worth to make a lokal cObj for that and hand over the complete data. So you are able to use alle fields in TypoScript. F.e. field = bodytext in your case.
# create lokal cObj - do not override the original data!
$cObj = t3lib_div::makeInstance('tslib_cObj');
foreach ($row = ...) {
# override data array with row. Every field in $row is now accesible via
# TypoScript field = fieldname
$cObj->start($row, $tableName);
$content .= $cObj->stdWrap($row['bodytext'], $this->conf['bodytext.']);
}
# TS Setup:
# in your case you could do somesthing like:
plugin.tx_yourplugin_pi1 {
bodytext.parseFunc < lib.parseFunc_RTE
bodytext.wrap = <div class="hide">|</div>
bodytext.prepend = TEXT
bodytext.prepend.field = bodytext
bodytext.prepend.stripHtml = 1
bodytext.prepend.crop = 30 | ... | 1
bodytext.prepend.wrap = <span title="|" onclick="showBodytext()">info</span>
}
If you need it in an user function try it like this:
function user_yourfunction($content,$conf) {
$result = *magic*
$cObj = t3lib_div::makeInstance('tslib_cObj');
$cObj->start($result, 'your table name');
return $cObj->stdWrap($result['bodytext'], $conf['bodytext.']);
}
In TypoScript:
includeLibs.something = media/scripts/example_callfunction.php
page.10 = TEXT
page.10 {
value = Hello World
postUserFunc = user_yourfunction
postUserFunc.bodytext.parseFunc < lib.parseFunc_RTE
}
I have my homepage http://www.faberunashop.com set up as a directory. When you click on the post image, it takes you over to the artists site. Here is the code that I used to make this happen by adding it to the functions.php:
function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='url1' || $pkey=='title_url' || $pkey=='url_title') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '<h2>'.$title.'</h2>';
}
Now I want to do the same to my search and archive page. What do I adjust to make them behave the same?
I suppose that you use WordPress.
In that case you can change the layout and the behavior of your search results by creating a file with name search.php into your theme for your search results, and another file for archives that called archives.php.
For more information about Template Hierarchy for WordPress you can find here http://codex.wordpress.org/Template_Hierarchy