<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cozmoslabs &#187; search box</title>
	<atom:link href="http://www.cozmoslabs.com/tag/search-box/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cozmoslabs.com</link>
	<description>Web design and development experiment.</description>
	<lastBuildDate>Fri, 03 Feb 2012 16:05:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Add a search box to the thematic menu</title>
		<link>http://www.cozmoslabs.com/358-add-a-search-box-to-the-thematic-menu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=add-a-search-box-to-the-thematic-menu</link>
		<comments>http://www.cozmoslabs.com/358-add-a-search-box-to-the-thematic-menu/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 23:53:46 +0000</pubDate>
		<dc:creator>Cristian</dc:creator>
				<category><![CDATA[Recomended Reading]]></category>
		<category><![CDATA[Thematic]]></category>
		<category><![CDATA[Theme Design]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[child theme]]></category>
		<category><![CDATA[search box]]></category>

		<guid isPermaLink="false">http://www.cozmoslabs.com/?p=358</guid>
		<description><![CDATA[A search box in main menu is something a lot of themes have by design. Although this is not the case with the Thematic Theme Framework, it&#8217;s easy to customize it with a few lines of code. First thing we need to do is create a thematic child theme. This way we won&#8217;t make direct [...]
Related posts:<ol>
<li><a href='http://www.cozmoslabs.com/202-replacing-the-thematic-menu-with-a-dropdown-list-of-categories/' rel='bookmark' title='Replacing the Thematic Menu with a DropDown List of Categories'>Replacing the Thematic Menu with a DropDown List of Categories</a></li>
<li><a href='http://www.cozmoslabs.com/284-thematic-drop-down-menu/' rel='bookmark' title='Drop Down Menu for Thematic'>Drop Down Menu for Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/300-quickly-add-a-category-dropdown-to-thematic-09/' rel='bookmark' title='Quickly add a Category DropDown to Thematic 0.9'>Quickly add a Category DropDown to Thematic 0.9</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A search box in main menu is something a lot of themes have by design. Although this is not the case with the <a href="http://themeshaper.com/thematic/">Thematic Theme Framework</a>, it&#8217;s easy to customize it with a few lines of code.</p>
<p>First thing we need to do is <a href="http://www.cozmoslabs.com/2008/09/07/use-wordpress-as-a-cms-with-thematic-part1/">create a thematic child theme</a>. This way we won&#8217;t make direct changes to Thematic.</p>
<p>The search box will be displayed on the right of the menu, inside of the <em>#access</em> div. The way Thematic hooks and actions were constructed will first need to remove the <em>thematic_access()</em> action from the <em>thematic_header()</em> hook. If all this sounds a bit difficult fear not. All you have to do is add this code inside of <em>functions.php</em> file of your child theme (don&#8217;t forget the <em><&#63;php</em> opening tag and the <em>&#63;></em> ending tag).</p>

<div class="wp_codebox"><table><tr id="p3583"><td class="code" id="p358code3"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Remove default Thematic actions</span>
<span style="color: #000000; font-weight: bold;">function</span> remove_thematic_actions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thematic_header'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'thematic_access'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'remove_thematic_actions'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>php<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #b1b100;">If</span> everything is working properly when you reload your Wordpress installation the entire menu would have disappear<span style="color: #339933;">!</span> <span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span>Now we can create our own menu WITH the search box on the right of it<span style="color: #339933;">!</span> <span style="color: #339933;">&lt;/</span>strong<span style="color: #339933;">&gt;</span>Add this code at the <a href="http://www.php.net/end"><span style="color: #990000;">end</span></a> of your <span style="color: #339933;">&lt;</span>em<span style="color: #339933;">&gt;</span>functions<span style="color: #339933;">.</span>php<span style="color: #339933;">&lt;/</span>em<span style="color: #339933;">&gt;:</span>
&nbsp;
<span style="color: #339933;">&lt;</span>pre lang<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;php&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #666666; font-style: italic;">// Create a custom access div with the menu and search box</span>
<span style="color: #000000; font-weight: bold;">function</span> search_access<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    	<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;access&quot;</span><span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;skip-link&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#content&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php _e('Skip navigation to the content', 'thematic'); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Skip to content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thematic'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_page_menu<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sort_column=menu_order'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;access-search&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;</span>form id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;searchform&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;get&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php bloginfo('home') ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;s&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;s&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo wp_specialchars(stripslashes(<span style="color: #006699; font-weight: bold;">$_GET</span>['s']), true) ?&gt;&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;20&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1&quot;</span> <span style="color: #339933;">/&gt;</span>
						<span style="color: #339933;">&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;searchsubmit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;searchsubmit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php _e('Search', 'thematic') ?&gt;&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> <span style="color: #339933;">/&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
        <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#access --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thematic_header'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'search_access'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Reload your page and the search box will be there, but not where you expected it to be! We&#8217;ll need to add a bit of css styling to it. </p>
<p>Go ahead and open the <em>style.css</em> and at the end of it add this css code:</p>

<div class="wp_codebox"><table><tr id="p3584"><td class="code" id="p358code4"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#access-search</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">260px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">170px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">29px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>This is it! You now have successfully added a search box to the right of your thematic main menu! </p>
<div id="preview_download" style="text-align:center">
<a href="http://www.cozmoslabs.com/projects/wp/?theme=indepth" target="_blank"><img src="http://www.cozmoslabs.com/wp-content/plugins/download-monitor/img/preview.gif" alt="Preview of the finished search box"/></a></div>
<p>Related posts:<ol>
<li><a href='http://www.cozmoslabs.com/202-replacing-the-thematic-menu-with-a-dropdown-list-of-categories/' rel='bookmark' title='Replacing the Thematic Menu with a DropDown List of Categories'>Replacing the Thematic Menu with a DropDown List of Categories</a></li>
<li><a href='http://www.cozmoslabs.com/284-thematic-drop-down-menu/' rel='bookmark' title='Drop Down Menu for Thematic'>Drop Down Menu for Thematic</a></li>
<li><a href='http://www.cozmoslabs.com/300-quickly-add-a-category-dropdown-to-thematic-09/' rel='bookmark' title='Quickly add a Category DropDown to Thematic 0.9'>Quickly add a Category DropDown to Thematic 0.9</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.cozmoslabs.com/358-add-a-search-box-to-the-thematic-menu/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
	</channel>
</rss>

