Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Header configuration & styling »

Add Google CSE Code and enable a Google custom search


  #1  
Old Jul 23, 2013, 11:17 AM
dherrhoyman's Avatar
dherrhoyman
 
2 posts · Jul 2013
Madison WI
After having gone around on how Atahualpa works and Google CSE works (today),
I have hacked my theme to get a search to work out of the header.
Pretty sure I could add in another theme edit variable (the Google CSE code)
and make it add in the relevant bits. This would be if you had the header search box ON,
then if this yet-to-be-added setting where defined (not blank), it would add in the relevent
bits. This is partly for my own self interest (don't want the next update to blow away
my changes) and partly a contribution so others don't have to do this hack.

I think I can figure this out or would follow the directions on what's kosher
in added such a setting. I can also explain how to make a search results page
work too. See http://snapplus.wisc.edu for what I have going now.

Done things like this before in Moodle and Joomla.
Shoot I'd just edit the Atahualpa source code, if I were made a committer.
Or I could do a diff and send it to whomever.
Just let me know!

--Dirk Herr-Hoyman
  #2  
Old Jul 23, 2013, 01:00 PM
juggledad's Avatar
juggledad
 
23,684 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Why not try one of the google CSE plugins?
  #3  
Old Jul 23, 2013, 01:21 PM
dherrhoyman's Avatar
dherrhoyman
 
2 posts · Jul 2013
Madison WI
That only gets you part way there.
I am using the Google Custom Search plugin, but the
search in the header doesn't switch to the CSE.
I have hacked it in by directly modifying bfa_header_config.php (see below).
If the <insert CSE code> had a theme setting variable, and there was another if/then,
it would work:

// Search box
if ( $bfa_ata['show_search_box'] == "Yes" )
{

/*
echo '<td valign="bottom" class="search-box" align="right"><div class="searchbox">
<form method="get" class="searchform" action="' . $homeURL . '/">
<div class="searchbox-form">' .
// Since 3.6.8: Removed check whether get_search_query() exists and added esc_js
'<input type="text" class="text inputblur" onfocus="this.value=\'' .
( get_search_query() ? esc_js(get_search_query()) : '' ) . '\'"
value="' . ( get_search_query() ? esc_js(get_search_query()) : esc_attr($bfa_ata['searchbox_text']) ) .
'" onblur="this.value=\'' . ( get_search_query() ? esc_js(get_search_query()) :
esc_attr($bfa_ata['searchbox_text']) ) . '\'" name="s" />' .
'</div>
</form>
</div>
</td>';
*/
/**/
echo '<td valign="bottom" class="search-box" align="right"><div class=searchbox><div>' .
'<script>
(function() {
var cx = "<insert CSE code here>";
var gcse = document.createElement("script");
gcse.type = "text/javascript";
gcse.async = true;
gcse.src = (document.location.protocol == "https:" ? "https:" : "http:") +
"//www.google.com/cse/cse.js?cx=" + cx;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox-only></gcse:searchbox-only>' .
'</div></div></tr>
';
/**/
}

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Custom Search gnosis Plugins & Atahualpa 15 May 31, 2013 04:27 PM
Adding Google Custom Search gnosis Header configuration & styling 13 Sep 17, 2012 05:25 AM
[SOLVED] Google Custom Search Widget not working. simonsaysgo Sidebars & Widgets 1 Jan 6, 2010 08:27 PM
google custome search code saifullahraza Plugins & Atahualpa 1 Sep 17, 2009 02:11 PM
Google Custom Search Plugin upscho Plugins & Atahualpa 0 Feb 27, 2009 04:51 AM


All times are GMT -6. The time now is 02:51 AM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.