Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅显示动态生成的页面标题的路径数组中的最后一项_Php_Mysql - Fatal编程技术网

Php 仅显示动态生成的页面标题的路径数组中的最后一项

Php 仅显示动态生成的页面标题的路径数组中的最后一项,php,mysql,Php,Mysql,我还是一个比较新的PHP用户,我的网站经常让我头疼,所以如果这个问题很愚蠢,我很抱歉——如果是这样,请给我指出正确的方向 我会尽力解释的。我在一个网站上工作,该网站使用PHPmyDirectory动态生成页面,从而生成页面标题和面包屑。我正试图找到一种生成自定义页面标题的方法——或者根据某个页面的url生成一个真正的自定义页面标题,甚至只是修改现有脚本,使其不包含标题中的整个路径 现在-它将生成如下页面标题: 芝加哥-伊利诺伊-美国-漫画艺术家-关于面孔娱乐 我希望它只是说“Chicagolan

我还是一个比较新的PHP用户,我的网站经常让我头疼,所以如果这个问题很愚蠢,我很抱歉——如果是这样,请给我指出正确的方向

我会尽力解释的。我在一个网站上工作,该网站使用PHPmyDirectory动态生成页面,从而生成页面标题和面包屑。我正试图找到一种生成自定义页面标题的方法——或者根据某个页面的url生成一个真正的自定义页面标题,甚至只是修改现有脚本,使其不包含标题中的整个路径

现在-它将生成如下页面标题: 芝加哥-伊利诺伊-美国-漫画艺术家-关于面孔娱乐

我希望它只是说“Chicagoland漫画艺术家-关于Faces Entertainment”,或者允许我使用页面url在某些关键位置和类别上替换自定义页面标题。“伊利诺伊州”和“美国”是“芝加哥”的母地

我想,我已经识别了相关的代码,但它似乎同时生成了面包屑和页面标题,我不想把面包屑弄得一团糟

有人能为我提出实现这两种选择的最佳方法吗

以下是我相信的代码:

    $category_template_id = $listing['primary_category_id'];

$listing_categories = $PMDR->get('Listings')->getCategories($listing['id']);

foreach($listing_categories as $key=>$category) {
    $category_path = $PMDR->get('Categories')->getPath($category['id']);
    if($category['id'] == $listing['primary_category_id']) {
        // Set page title, and breadcrumb
        foreach((array) $category_path as $category) {
            $PMDR->setAdd('page_title',$category['title']);
            $template_content->set('category_name', $category['title']);
            $PMDR->setAddArray('breadcrumb',
array('link'=>
$PMDR->get('Categories')->getURL($category['id'],$category['friendly_url_path']),
'text'=>$category['title']));
        }
    }
    $listing_categories[$key]['path_url'] = 
$PMDR->get('Categories')->getPathDisplay($category_path,'»');
}
unset($category_path);
// Set page title
$PMDR->setAdd('page_title',$listing['title']);

//Set Unique Listing ID

$template_content->set('unique_listing_id', $listing['unique_listing_id']);

// Set META description
if(!empty($listing['meta_description'])) {
    $PMDR->set('meta_description',$listing['meta_description']);    
} elseif(!empty($listing['description_short'])) {
    $PMDR->set('meta_description',$listing['description_short']);    
} else {
    $meta_description = $listing['title'];
    foreach((array) $category_path as $category) {
        $meta_description .= ' '.$category['title'];
    }
    foreach((array) $listing_locations as $location) {
        $meta_description .= ' '.$location['title'];
    }
    $PMDR->set('meta_description',$PMDR->getConfig('meta_description_default').' '.$meta_description.'.');
    unset($meta_description);    
}
我想我可以隔离位置路径数组中的最后一项,这可能是最简单的,但我看不到在代码的页面标题部分中调用位置信息的位置。我确实看到了它的进一步发展——它设置了元描述,但没有设置页面标题。我错过了吗?

在管理面板中,转到

并在搜索引擎优化下添加以下内容

默认元标题(元标题列表默认) 如果单个列表没有输入特定的元标题,将使用的默认元标题。可以使用以下变量:title、category_X,其中“X”是类别级别、location_X,其中“X”是位置级别、location_text_X,其中“X”是位置文本级别、zip和“custom_X”,其中“X”是自定义字段ID