Customizing joomla search result page layout - php

The joomla search results appear on the home page. I want it to show up on a new page. According to some online posts I had to modify the mod_search.php to set the item id to a non existing item so i set it to 0, but the problem is that the changes are not being reflected in my search module at all. I also tried putting a hidden field called itemid in the modules/mod_search/tmpl/default/default.php form but even that is not picked, I set the form target equal to _blank and tried to change the action page of the form to say index.php?Itemid=0 instead of index.php but all of this does not seem to reflect on the search module. When i manually change the itemid in the browser location box to 0, the results show up on a different page (thats what i want).
Please suggest what should I do?

Try to change request method of search form:
<form ... method="get">
<input type="hidden" name="itemId" value="0" />
or like this
<form action="...?itemId=0" method="post">

In Joomla 2.5 there is "itemId" field in mod_search properties, if set it to some non existent item than it clean ups search results page from modules which binding to some exact menu items(pages) and left only modules which are binding to "All" pages.

I know this is an older post, but I have found an easy solution for this for use with Joomla 1.6 and wanted to share it. It is a core hack, which isn't optimal because it will go away during upgrades, but it is easy to do.
What folks (like me) have been searching for is to allow a user to enter text in the search box on a page and have the results display in a blank page within the template, rather than have the results display within the same page along with other content, or be forced to use a menu item to send users to a separate search page.
When using a Search box within the Joomla! page to initiate a search, it is the 'component' portion -- not the 'module' -- of Search that is being used. There is a section in the Search Component Controller that either sets an ID for use with a menu, or automatically sets the result to come from and display in the requesting page. We just need to turn that off to send the search results to a blank page.
So, in /components/com_search/controller.php -- comment out the following code:
/* // set Itemid id for links from menu
$app = JFactory::getApplication();
$menu = $app->getMenu();
$items = $menu->getItems('link', 'index.php?option=com_search&view=search');
if(isset($items[0])) {
$post['Itemid'] = $items[0]->id;
} else if (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
$post['Itemid'] = JRequest::getInt('Itemid');
}
*/
This will display the search results within the content portion of a blank page of your template. At least it did for me.

Related

Joomla Ghost URL

I have an issue where a component link is passed correctly in the fact that the correct page is returned. But the "Option" part of the URL is shown incorrectly.
index.php/component/projxproject/projectform
is what should be passed, but
index.php/dashboard/projectform
is what is passed.
I have a component com_proxproject, whithin it, is a various set of views, project form, project, project list ect, and a view called dashboard, which is a roll-up of other info.
I created a Menu / Dashboard icon set with links to the various pages, but the paths are changed form what should be. example:
href="<?php echo 'index.php?option=com_projxproject&view=projectform&id=. 0', false, 0; ?>"
to the other one with dashboard in it. Its still goes to the page but I'm currently trying to filter Menus and Menu Items based on the "option" variable of the URL and the "/Dashboard/" is messing it up.
Any help would be great.
EDIT!!!!
I have solved 2 of 3 issues. This is due to Joomla's routing trough the menu links, the solution to the one above is:
href="<?php echo ('index.php?&Itemid='. 357); ?>"
Still working on one with no menu link. The links for articles ...in my case reports...are created individually as in, connecting to a particular article/report, I don't want to and cant create links to every item, so I need to pass a link with the item->id not just the menu ItemID...

Where to find a list of pages automatically renderable in Drupal and how it works?

In the pages .tpl.php of my theme i can find several lines like
render($action_links)
displaying whole pages with a single command. Sometime i saw that the render argument is a block from my theme .info, but other times i see arguments i cannot identify that render default pages or elements of drupal.
How it works? And where i can find a list of default displayable pages?
In particular, i needed to display the content of the default drupal page "add content" in one of my pages, and i'm pretty sure i can do it using this render method, but i cannot find the correct argument.
EDIT: I found something like
drupal_render(node_add('NODE_TYPE'));
that seems to allow the display of a node add form, but what i need is the main add content page, containing the list of all the type of nodes that a user can add.
Are you new to Drupal? When I read your post, I'm almost sure that you have missed something with the Drupal's working. The variables you found in render() functions are "calculated" somewhere else in the code (in the modules part for the most).
You cannot find a list of constant variables to display them just like this.
I found this article about these mysterious variables that are rendered and I hope it will help: http://newsignature.com/articles/the-magic-behind-drupals-render-elements
If you just want to display the "add content" form somewhere on your site, just call its path (node/add).
EDIT AFTER CLARIFICATIONS:
First of all, you can set on which page you want the user lands after login. (I don't know why you're still talking about user profile template. Maybe I missed something again.)
But if I did understand what you're trying to achieve, I'll do that:
Create a menu (or simply use the "Navigation" menu that seems to be exactly what you need) with all the actions users can do. And I'll place this menu in the main content region. Do create a menu, go to Administration>Structure>Menus>Add menu. And add links like "node/add/article" or "node/add/news" or "node/add/page" or whatever your content-types are.
Place this menu in the region you want. If you want it to be like the main content of the page, place it in the main container. To do so, go to Administration>Structure>Blocks> Drag and drop your menu in the right region and Save.
Configure this block to appear only on the front page (the first page on user arrives after logged in) if you want so. To do so, in the Blocks administration page, click on "Configure" next to your block and check "show block on specific pages: Only the listed pages" and write down <front>
Create roles and permissions for your different sorts of users. That will automatically show them the links they are allowed to see. To set permissions, go to Administration>People>Permissions and check in the "Node" section which content-type each role can create.
I hope I didn't forget anything. Please tell me if it is clear enough.

How to check which menu item has been selected in Form Load in Joomla

I am running Joomla and using the ChronoForms plug component to create Forms.
I have a problem in that I want to set menu items on a menu in Joomla but want to make use of querystrings so more than one menu item might have the same Form Name but a different querystring. However it isn't possible to use querystrings in menu items with ChronoForms.
One possible solution I am investigating is to do away with querystrings and just check on Form Load which menu item has been selected and then process the form accordingly.
Has someone any ideas how to do this?
I am not sure what you are asking here, but i you wish to have multiple menu items pointed to the same form, you can do this by manually editing the menu item alias. Am I following what you are trying to accomplish?
Look at the menu link created by ChronoForms, when you add it to a menu (without querystring). You can use that as a base for an 'external URL', where you can add whatever you want to it.

Search form controller

I am trying to create a Generic Search form (Controller) object. As in my website I have 4 different search forms, like
at Start Page I have a search form and on List page I have again a search form with more filters and on product page Have a search form with product specific property filters.
And what I want is that when user comes back from product page to list page, all the filters should a selected again automatically and if the user was on page 3 (pagination) the he should land again on page 3. Similarly from list to start, all the selected options should be populated again.
Is there any example available?
You could store this information in session variables.
For example, each time a list page is loaded, its number could be added to a $_SESSION["page_number"]; variable. Then whenever the list page loads again (being navigated from the product page for instance), the session value is used to retrieve the last viewed page. The form filters and other options could be stored in the same manner.

Drupal 6 dynamic menu item

I need to create a menu item, which changes its title and link if a user has a certain condition, or not.
Drupal caches all the menues, so i can't really think of a way to do that.
For example, user has a node attached to his profile, menu item is "Create blabla" (link node/add/blabla)
User doesn't have the node, menu item is "Create notblablabla" (link node/add/notblabla)
The best and easiest way is to use hook_menu with param title_callback.
See thedrupalblog.com and drupal.org.
Drupal does not allow for dynamic menu items, but it can hide certain menu items if the user is not allowed to go there. Referring to your example, if you create both the links and use the permission system to restrict the creation of those node types to certain roles, Drupal will only show the menu items if the user has the required role. Maybe that helps in your situation.
Other options are:
write a simple module that shows a single link for all users and redirects to the appropriate page when clicked
create a custom block which displays the correct link based on the current user (make sure the block is not cached)
use javascript like googletorp suggest (although I wouldn't recommend it for the reasons he mentions)
A simple way to do this, would be to use JavaScript. You can alter HTML without much efford using jQuery. This will require that your users has JS enabled, so it's not a perfect solution.
Another option would be to have a single menu item, that linked to a url you created in a module. He you could do the condition check a redirect the user to whichever url he should be redirected to. The only problem with this method would be that the changing the title of the menu item. But you might be able to give a fitting description for both cases. You could also use JS to change the name of the link. That way you would keep the functionality intact without JS but improve the UI for users with it enabled.
I would probably create two menu items, and use the theme system to hide one or the other based on the condition.
It's been a while, but I'd look at:
http://drupal.org/node/223430
http://api.drupal.org/api/function/template_preprocess/6
http://api.drupal.org/api/function/phptemplate_preprocess_page/6
Since this menu item seems to be predicated on user profile information, I would suggest writing a simple module that implements hook_menu_alter() to alter the menu based on your condition. You can then call menu_cache_clear() inside hook_user() to renew the menu cache when the user profile changes.
Have you tried this (inserting your other conditions into the 'if' statement as well of course):
function hook_translated_menu_link_alter(&$item, $map) {
if ($item['href'] == 'node/add/blabla') {
$item['href'] = 'node/add/notblabla';
}
}
You'll probably also have to do this to mark the link as alterable:
function hook_menu_link_alter(&$item, $menu) {
if ($item['link_path'] == 'node/add/blabla') {
$item['options']['alter'] = TRUE;
}
}

Categories