Search & Other Blocks inside Templates

Permalink
Hi guys, just got a quick couple of questions that i cant seem to find via searching (maybe im using the wrong words)

Basically im want to be able to add the superfish menu block to all of my pages by default in the template file, is that possible ? ... so i dont need to add it each time i create a page ?

Also im trying to add a search box on the top right of each page via my templates as well, is this possible at all ?

any help or a point in the right direction would be appreciated

thanks

Liam

 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
You can code a block directly (and specify a view/block template) within a theme. Doing this means that the block will not be editable.

Alternatively, for a menu it is usually easier to have a Global Area within the header (usually this gets named 'Header Nav'). Then you can edit the block in one place and it is seen throughout all pages.

Have a look at the Greek Yogurt theme code, in particular concrete/themes/greek_yogurt/elements/header.php
jero replied on at Permalink Reply
jero
Superfish:

http://www.concrete5.org/marketplace/addons/superfish/questions-and...

http://www.concrete5.org/marketplace/addons/superfish/questions-and...

Search:

$search = BlockType::getByHandle('search');
$search->controller->title = 'Search';
$search->controller->buttonText = 'Go';
$search->controller->baseSearchPath = '';
$search->controller->resultsURL = DIR_REL.'/search/search-results';
$search->render('view');
JohntheFish replied on at Permalink Reply
JohntheFish
Apart from the overall method, are the other issues on those threads still applicable to current versions of C5?
jero replied on at Permalink Reply
jero
Certainly applicable to 5.4.2.2 - I used the search code this very day. Not sure about 5.5.x though - but it would be easy enough to try out and report back :)
liamb2001 replied on at Permalink Reply
thanks for getting back i changed to global in the template and its worked a treat so thanks for that, ill give the coding for the search a try and post my updates

thanks :)
liamb2001 replied on at Permalink Reply
sorry to sound dumb but ive put the code in as you mentioned

$search = BlockType::getByHandle('search');
$search->controller->title = 'Search';
$search->controller->buttonText = 'Go';
$search->controller->baseSearchPath = '';
$search->controller->resultsURL = DIR_REL.'/search/search-results';
$search->render('view');

but it is giving out errors, do i have to do more than just paste it inside of a div ??
JohntheFish replied on at Permalink Reply
JohntheFish
You should be able do the same global area method with a search block, within the block setting it to show the results on another page.
liamb2001 replied on at Permalink Reply
that worked thanks :)

I need just the search box & not the title but it wont let me leave it blank, i take it i need to take the code out from where its pulling that module from ? you dont happen to know where that is located do you ?


...sorry for all the questions
liamb2001 replied on at Permalink Reply
its ok i found it in the block, view.php

just need to replace the standard button now with one of my own but im sure ill manage, thanks for the quick and great help guys i really appreciate it....


Am absolutley loving this new version of Concrete !!! :)
liamb2001 replied on at Permalink Reply
hi back again sorry, ive noticed that including the search box using the method you mentioned in the top right corner of my design looks fine until you do a search then it shows the results in the top right corner instead of the main page, is there any way around that at all ?
JohntheFish replied on at Permalink Reply
JohntheFish
Use the option in the search block to set what page you want the results to show on.

Results Page:
Post to Another Page Elsewhere
liamb2001 replied on at Permalink Reply
sorry about this, its not like im not trying before im coming back on the forum, lol....

what am i supposed to put in the box for results page ?

I have tried the page ive created as an absolute link, ive tried it as index.php?cID=127 as well as the pretty url (just incase) and ive even tried it without and it doesnt seem to make any difference ??
JohntheFish replied on at Permalink Reply
JohntheFish
The path to another page within your site that also has a search block on it. For example, the default sample content includes a page at /search/ with a search block and space for results.

So, in your header search block, you enter /search/ in the other page part.
liamb2001 replied on at Permalink Reply
Hmmm ive tried /search/ as you said as the in the Results Page box but when doing a search i get Page Not Found
No page could be found at this address.

have a look here
http://www.mountainmomentum.co.uk/index.php...
JohntheFish replied on at Permalink Reply
JohntheFish
Thats because you have called the page /search-results/ on your site - see the RHS of the navigation bar.
liamb2001 replied on at Permalink Reply
i tried with /search/ as well but with same results
liamb2001 replied on at Permalink Reply
if you look now /search/ but its not working

any ideas at all mate ?
liamb2001 replied on at Permalink Reply
ive noticed its despite using /search/ it the link uses

http://www.mountainmomentum.co.uk/index.php/search/?search_paths[]=...

has index.php in the middle, is that right ?

Ive removed the default pages from the site, could it be that ive removed search ? if so how do i go about adding it again do i just create a standard page called search or does it have to have special properties or code in it ?

sorry for all these questions, ive spent ages on this and just want to get it righ , youve been a great help and i appreciate you trying
JohntheFish replied on at Permalink Reply
JohntheFish
You need to put a search block in the Main area of the /search/ page.
liamb2001 replied on at Permalink Reply
right ok will give it a try
liamb2001 replied on at Permalink Reply
ive added search again but its still not working its shouing the results underneath, would really appreciate some help now
liamb2001 replied on at Permalink Reply
almost there, its giving results under the search box as well, any idea how i go about removing that ?, also is it possible to hide the Search link from my suprfish menu at all ?
liamb2001 replied on at Permalink Reply
Do you know how to remove the results from the block and just leave them on the main page ?
JohntheFish replied on at Permalink Reply
JohntheFish