Customize Search Block

Permalink
I have a homepage that requires different CSS for the search block than the rest of the site. I copied the search folder and renamed it, I changed the getByHandle to reflect the different folder.

<?php
    $bt_search = BlockType::getByHandle('search'); 
   $bt_search->controller->resultsURL = '/search-results';               
    $bt_search->render('view');
    ?>

Then I get Fatal error: Call to undefined method stdClass::render()

Any help would be appreciated.

kevin001
 
kevin001 replied on at Permalink Reply
kevin001
Code correction, the code is:
<?php
    $bt_search = BlockType::getByHandle('search_home'); 
   $bt_search->controller->resultsURL = '/search-results';               
    $bt_search->render('blocks/view');
    ?>
Shotster replied on at Permalink Reply
Shotster
If you actually need to change ONLY the CSS, then why not just edit the style sheet? If in fact you do need to customize the mark-up, then you should probably create a custom template. See here...

http://www.concrete5.org/documentation/general-topics/custom-templa...

http://www.concrete5.org/community/forums/customizing_c5/contributi...

-Steve
kevin001 replied on at Permalink Reply
kevin001
But I need a different CSS between the homepage and the interior pages. I have the interior working fine using the default search block.
dg1 replied on at Permalink Reply
In your header, assign an id to the body like:
<body id="<?php echo $c->getCollectionTypeHandle() ?>">.

This will result in <body id="home"> for the home page. You can then set up the styles in your css for #home. For example:

#home { background-image: url(../images/home_bg.jpg); background-repeat: repeat-x; }

Anyway, that's one way to do it.
kevin001 replied on at Permalink Reply
kevin001
That is not a bad idea, can't believe I didn't think about just changing elements in the CSS. I'll give that a try.
kevin001 replied on at Permalink Reply
kevin001
What I ended up doing is removing the styles from the CSS and placing them on the individual page types, worked great.