Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic Page Titles for articles and categories #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions templates/shaper_helixultimate/features/title.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php
/**
* @package Helix_Ultimate_Framework
* @author JoomShaper <[email protected]>
* Copyright (c) 2010 - 2021 JoomShaper
* @version 1.0.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
*/


defined ('_JEXEC') or die();

use Joomla\CMS\Factory;
Expand Down Expand Up @@ -37,6 +35,7 @@ class HelixUltimateFeatureTitle
*/
public function __construct($params)
{
$this->params = $params; // اضافه شده برای تنظیم پارامترها
$this->position = 'title';
}

Expand All @@ -48,26 +47,23 @@ public function __construct($params)
*/
public function renderFeature()
{

$app = Factory::getApplication();
$menuitem = $app->getMenu()->getActive();
$menuitem = $app->getMenu()->getActive();

if($menuitem)
if ($menuitem)
{

$params = $menuitem->getParams();

if($params->get('helixultimate_enable_page_title', 0))
if ($params->get('helixultimate_enable_page_title', 0))
{

$page_title = $menuitem->title;
$page_heading = $params->get('helixultimate_page_title_heading', 'h2');
$page_title_alt = $params->get('helixultimate_page_title_alt');
$page_subtitle = $params->get('helixultimate_page_subtitle');
$page_title = $menuitem->title;
$page_heading = $params->get('helixultimate_page_title_heading', 'h2');
$page_title_alt = $params->get('helixultimate_page_title_alt');
$page_subtitle = $params->get('helixultimate_page_subtitle');
$page_title_bg_color = $params->get('helixultimate_page_title_bg_color');
$page_title_bg_image = $params->get('helixultimate_page_title_bg_image');

if($page_heading == 'h1')
if ($page_heading == 'h1')
{
$page_sub_heading = 'h2';
}
Expand All @@ -78,36 +74,59 @@ public function renderFeature()

$style = '';

if($page_title_bg_color)
if ($page_title_bg_color)
{
$style .= 'background-color: ' . $page_title_bg_color . ';';
}

if($page_title_bg_image)
if ($page_title_bg_image)
{
$style .= 'background-image: url(' . Uri::root(true) . '/' . $page_title_bg_image . ');';
}

if($style)
if ($style)
{
$style = 'style="' . $style . '"';
}

if($page_title_alt)
if ($page_title_alt)
{
$page_title = $page_title_alt;
$page_title = $page_title_alt;
}

// بررسی اگر صفحه جاری یک صفحه مطلب است و تنظیم عنوان مطلب
$input = $app->input;
$option = $input->getCmd('option');
$view = $input->getCmd('view');
$id = $input->getInt('id');

if ($option == 'com_content' && $view == 'article' && $id)
{
// دریافت عنوان مطلب از جوملا
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = ' . (int) $id);
$db->setQuery($query);
$article_title = $db->loadResult();

if ($article_title)
{
$page_title = $article_title;
}
}

$output = '';

$output .= '<div class="sp-page-title"'. $style .'>';
$output .= '<div class="sp-page-title" ' . $style . '>';
$output .= '<div class="container">';

$output .= '<'. $page_heading .' class="sp-page-title-heading">'. $page_title .'</'. $page_heading .'>';
$output .= '<' . $page_heading . ' class="sp-page-title-heading">' . $page_title . '</' . $page_heading . '>';

if($page_subtitle)
if ($page_subtitle)
{
$output .= '<'. $page_sub_heading .' class="sp-page-title-sub-heading">'. $page_subtitle .'</'. $page_sub_heading .'>';
$output .= '<' . $page_sub_heading . ' class="sp-page-title-sub-heading">' . $page_subtitle . '</' . $page_sub_heading . '>';
}

$output .= '<jdoc:include type="modules" name="breadcrumb" style="none" />';
Expand All @@ -116,10 +135,7 @@ public function renderFeature()
$output .= '</div>';

return $output;

}

}

}
}