Search results in title show html tag

Everything to do with Joomla! 3.x templates and templating.

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.
Post Reply
zuco
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Oct 24, 2017 9:52 am

Search results in title show html tag

Post by zuco » Tue Oct 24, 2017 10:03 am

Hi,

this is my problem in search, have tags in title off search

1. <span class="highlight">misijska</span> djelatnost Crkve
(Kategorija)
Kreirano 2014-04-14 20:48:38

2. <span class="highlight">misijska</span> nedjelja u Nadbiskupiji
(Vijesti)
...

I have Joomla 3.8.1. and read article about this to delete line 270 in com_search/view/search/view.html.php but i didnt get resalt.

Pleas help!

zuco
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Oct 24, 2017 9:52 am

Re: Search results in title show html tag

Post by zuco » Tue Oct 24, 2017 1:04 pm

Found solution, in templete folder html/com_search/search/default_results.php

Change in line 19 and 22 from:

echo $this->escape($result->title);

with

echo $this->escape(strip_tags($result->title));

and its working.

User avatar
marcofloriano
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Tue Aug 10, 2010 1:56 am
Location: Brazil
Contact:

Re: Search results in title show html tag

Post by marcofloriano » Wed Mar 14, 2018 5:28 pm

Thanks for the solution

Ambroz
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Sep 12, 2018 5:33 pm

Re: Search results in title show html tag

Post by Ambroz » Wed Sep 12, 2018 8:02 pm

Hi.
I'm having the same problem as the autor of the topic. I'm using a Yoo Master 2 Template and the Joomla is 3.8.12
my default_results.php looks like this:

Code: Select all

<?php
/**
* @package   yoo_master2
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl.html GNU/GPL
*/

// include config and layout
$base = dirname(dirname(dirname(__FILE__)));
include($base.'/config.php');
include($warp['path']->path('layouts:'.preg_replace('/'.preg_quote($base, '/').'/', '', __FILE__, 1)));
default_results-20180912-172442.php

Code: Select all

<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_search
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

?>
<dl class="search-results<?php echo $this->pageclass_sfx; ?>">
<?php foreach ($this->results as $result) : ?>
	<dt class="result-title">
		<?php echo $this->pagination->limitstart + $result->count . '. '; ?>
		<?php if ($result->href) : ?>
			<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) : ?> target="_blank"<?php endif; ?>>
				<?php // $result->title should not be escaped in this case, as it may ?>
				<?php // contain span HTML tags wrapping the searched terms, if present ?>
				<?php // in the title. ?>
				<?php echo $result->title; ?>
			</a>
		<?php else : ?>
			<?php // see above comment: do not escape $result->title ?>
			<?php echo $result->title; ?>
		<?php endif; ?>
	</dt>
	<?php if ($result->section) : ?>
		<dd class="result-category">
			<span class="small<?php echo $this->pageclass_sfx; ?>">
				(<?php echo $this->escape($result->section); ?>)
			</span>
		</dd>
	<?php endif; ?>
	<dd class="result-text">
		<?php echo $result->text; ?>
	</dd>
	<?php if ($this->params->get('show_date')) : ?>
		<dd class="result-created<?php echo $this->pageclass_sfx; ?>">
			<?php echo JText::sprintf('JGLOBAL_CREATED_DATE_ON', $result->created); ?>
		</dd>
	<?php endif; ?>
<?php endforeach; ?>
</dl>
<div class="pagination">
	<?php echo $this->pagination->getPagesLinks(); ?>
</div>
Can you help me to get rid of the html tags?


Post Reply

Return to “Templates for Joomla! 3.x”