Keyword

[SOLVED] Common search/tag results page for all categories?

More
10 years 11 months ago #119774 by Jamie
Hi,

I'm developing my first site - thank you for all the useful information on here that I've made use of so far. I have encountered some problems though with combining category-specific layouts with a common layout for search/tag cloud results - I'm hoping someone can point me in the right direction....

For two K2 tools modules (search box, tag cloud), I have used the layout settings in K2 Parameters and modified the generic.php and tag.php files in my K2 sub-template to style the results as needed. So far, so good.

The issue I'm having however is that the search/tag results pages themselves seem to inherit their layout from the page from where the search was initiated, or where the tag cloud was clicked.

For example, for one category I'd like the pages to appear in two columns - item content to the left; another module position to the right (custom HTML, or K2 split content). I've successfully managed to get this to appear OK through both:

a. Publishing the additional module to the same position as the component and then styling to display in two columns; or
b. Publishing the additional module to a collapsible position, specified within the joomla index.php.

Regardless of which of the above approach I use though, if I perform a search or click on a tag within the tag cloud from this differently styled page (category), the search/tag results are just generated in the left-hand column only - and the additional module remains visible to the right.

Ideally, I'd like the additional, category-specific modules published to the right to disappear and the search results to be generated across the full page. The search/tag results would therefore appear consistently throughout the site.

Is this possible, or does anyone know of a better way to approach category-specific page layouts that would allow me to do this?

Grateful for any guidance!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 11 months ago #119775 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Common search/tag results page for all categories?
Hello Jamie,

You can solve this for search result quite easily.

Create a hidden menu item for search results and copy its ID.
Then in your search box overrides make the search form post in that menu item ID.

This way the search results will have their own menu item which you can control its layout and modules.

You can do this by changing the jRoute:: parameters and adding a &Itemid=THE_ID at the end.

Then add <input type="hidden" name="Itemid" value="THE_ID" /> to the set of the hidden inputs. (Inside the SEF php check).

As for the tags, you can either map them to menu items if you are using a fixed number of tags or use try to assign all of your categories to a menu item so you will have a base menu item where tags will be rendered.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #119776 by Jamie
Hi Krikor,

Thanks for your response. Putting the tags to one side, I've attempted to implement your suggestions on the search box. After creating the search results menu item, I think I managed to confuse myself trying to make the changes you suggested.

I hadn't appreciated that I could actually use the standard joomla search module/component to return k2 articles. I also discovered that the basic module settings in the back-end for the standard joomla search module have a field to 'set Item ID'. I've got this working OK using the item ID of my newly created search results menu item, but I then appear to have to settle for the default_results.php layout from the joomla search component, rather than the more flexible generic.php layout with the option to include images, tags etc.

Would you be prepared to describe exactly where I need to make the overrides you describe?

As far as I can tell I think I need to make these overrides in a version of ...\modules\mod_k2_tools\tmpl\search.php, but can't seem to get it to work.

Thanks again,

Jamie.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 10 months ago #119777 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Common search/tag results page for all categories?
Jamie,

It is wise to override instead of editing the core files.
This tutorial will help you. getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

In the search.php module the SEF check is in line 34.

The form's action is located around line 21.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119778 by Ian
Can you expand on this, i have tried a few things and it is not working. I believe the lines of code you are changing are:


<form action="<?php echo $action; ?>" method="get" autocomplete="off" class="k2SearchBlockForm">


and


<input type="hidden" name="categories" value="<?php echo $categoryFilter; ?>" />
<?php if(!$app->getCfg('sef')): ?>
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="itemlist" />
<input type="hidden" name="task" value="search" />
<?php endif; ?>

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119779 by Lefteris
@Ian

What's exactly the issue you are facing?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119780 by Ian
I am trying to redirect the search results to a new page, as opposed to inheriting the original page.

I created a new menu item, and copied the ID number. Does this menu item have to be something specific?

I then copied the \modules\mod_k2_tools\tmpl\search.php to create an override.

I am having trouble with these 2 instructions you provided:
  • You can do this by changing the jRoute:: parameters and adding a &Itemid=THE_ID at the end.

  • Then add <input type="hidden" name="Itemid" value="THE_ID" /> to the set of the hidden inputs. (Inside the SEF php check).

I have tried various configurations, and nothing has resulted in listing the search results on the menu item i specify.

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119781 by Lefteris
I don't know why you want to do this, but if you insist the menu item must be pointing to K2 not to other extension.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119782 by Ian
I am doing this to have control over the modules and header text that is displayed. Currently, if i am on a non k2 page, and i search, the resulting page will display "Search Results for: xxx". This makes sense for the user. If i am on a k2 page and i search, the original headers display. If i am searching for "dogs" from a "cat" page, and the search results fall under "cat", it is confusing for the user. Plus, i want to have control over the modules displayed.

I have changed my menu item, #123, to display a k2 item by default. I updated the code below (note the bold), and cannot figure it out:

<?php
/**
* @version 2.6.x
* @package K2
* @author JoomlaWorks www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2014 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
*/

// no direct access
defined('_JEXEC') or die;

/*
Important note:
If you wish to use the live search option, it's important that you maintain the same class names for wrapping elements, e.g. the wrapping div and form.
*/

?>

<div id="k2ModuleBox<?php echo $module->id; ?>" class="k2SearchBlock<?php if($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); if($params->get('liveSearch')) echo ' k2LiveSearchBlock'; ?>">
<form action="<?php echo $action; ?>&Itemid=123" method="get" autocomplete="off" class="k2SearchBlockForm">

<input type="text" value="<?php echo $text; ?>" name="searchword" maxlength="<?php echo $maxlength; ?>" size="<?php echo $width; ?>" alt="<?php echo $button_text; ?>" class="inputbox" onblur="if(this.value=='') this.value='<?php echo $text; ?>';" onfocus="if(this.value=='<?php echo $text; ?>') this.value='';" />

<?php if($button): ?>
<?php if($imagebutton): ?>
<input type="image" value="<?php echo $button_text; ?>" class="button" onclick="this.form.searchword.focus();" src="<?php echo JURI::base(true); ?>/components/com_k2/images/fugue/search.png" />
<?php else: ?>
<input type="submit" value="<?php echo $button_text; ?>" class="button" onclick="this.form.searchword.focus();" />
<?php endif; ?>
<?php endif; ?>

<input type="hidden" name="categories" value="<?php echo $categoryFilter; ?>" />
<?php if(!$app->getCfg('sef')): ?>
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="itemlist" />
<input type="hidden" name="task" value="search" />
<input type="hidden" name="Itemid" value="123" />
<?php endif; ?>
<?php if($params->get('liveSearch')): ?>
<input type="hidden" name="format" value="html" />
<input type="hidden" name="t" value="" />
<input type="hidden" name="tpl" value="search" />
<?php endif; ?>
</form>

<?php if($params->get('liveSearch')): ?>
<div class="k2LiveSearchResults"></div>
<?php endif; ?>
</div>

Please Log in or Create an account to join the conversation.

More
10 years 6 months ago #119783 by Lefteris
Try :
<form action="<?php echo JRoute::_('index.php?Itemid=123'); ?>" method="get" autocomplete="off" class="k2SearchBlockForm"> 

Also try to change the menu link to K2 categories ( don't select a category in the filter ).

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum