Jump to content
Sign in to follow this  
platinum

Adding Google +1 to header / icon section

Recommended Posts

platinum

Hi all, This is probably really simple, but I'm not having much success! I need to add a hook to get the Google +1 button up by the social icons near the site header. I have tried to do as this post suggest... http://www.pagelines.com/forum/discussion/comment/68726#Comment_68726 ..but given that the user 'thomstark' has had success in the post I refer to above, I'm confident that I am doing something wrong! I also checked out the video... http://www.pagelines.com/docs/base-child-theme Is someone able to post the entire code that I need for my fucntions.php (in base) to make this work? Please post the COMPLETE code for the base functions.php file. This is the first time I have ever tried to add a hook, so if I can see a complete file, I should be able to understand what I am doing wrong. the code for Google +1 is...

	 

Any assistance is much appreciated, thanks. P.S. As a temporary measure, I have added the Google +1 script to the universal sidebar, and added the universal sidebar to the 'site header' section of the 'template set up'... but it doesn't look that good, and I really need to understand how to add hooks once and for all!

Share this post


Link to post
Share on other sites
Jenny

Kate's previous answer seemed to help him. I'm not sure if you missed it (in the post you linked) but here is what she said:

Basically you would replace that anchor tag with the link to your Google plus page, as well as adding a unique class to it. So, more like this:
// add_action('hook_name','function name');
	
	add_action('pagelines_branding_icons_end', 'add_icons_to_branding');
	
	// function name
	function add_icons_to_branding(){
	?>
	
	<?php
	// what the function does??“in this case adds a stumbleupon icon to the header of your theme. The class referenced in the link can be seen in the style.css
	// and is the image from the CSS is placed in the images folder
	?>[/code]

For the icon: you could modify that sprite image and then re-upload it. Or, you could just upload a new image and assign that via CSS (using that "googleplus" class we created above). Either way would work fine.

So that is the code you will need. Be sure to follow her instructions for the image as well (using either the sprite image or CSS coding). Let us know how it goes!

Jenny :: Web designer at Simple Mama (follow me at @simplemamacom)

Check out Share Me, a social sharing add-on for DMS that is super simple to set up.

Share this post


Link to post
Share on other sites
platinum

Hi all, Thanks Simple_Mama for your reply. I have managed to get the google +1 script to show up in the header by modifying the example hook in that comes with base functions.php. So, because I am using a script and not an image, I don't need to use any css or sprite image, however, I did try to add another hook to learn a little more and I'm having some trouble... 2) here is the full child theme functions.php that is working...

<?php
	
	// Setup  -- Probably want to keep this stuff...
	// Set up action for section registration...
	add_action('pagelines_register_sections', 'base_sections');
	
	/**
	 * Hello and welcome to Base! First, lets load the PageLines core so we have access to the functions
	 */
	require_once( dirname(__FILE__) . '/setup.php' );
	
	// For advanced customization tips & code see advanced file.
		//--> require_once(STYLESHEETPATH . "/advanced.php");
	
	// ====================================================
	// = YOUR FUNCTIONS - Where you should add your code  =
	// ====================================================
	
	// ADDING CUSTOM SECTIONS ------- //
		// Register a Drag&Drop HTML Section for the admin.
		// A pullquote section was created here for demonstration purposes
	
		// Sections should be named: section.[your section name].php and placed in the sections folder.
	
		function base_sections(){
	
		/*
			Your custom sections get registered in here...
			PageLines Register Section Arguments:
				1. Section Class Name,
				2. Directory name (or filename if in root of 'sections' folder),
				3. Init Filename (if different from directory name),
				4. Section setup and variable array
	*/
	
			pagelines_register_section('BasePullQuote', 'pullquote', null, array('child' => true) );
			pagelines_register_section('BaseSidebar','sb_base', null, array('child' => true) );
	
		}
	
	// ABOUT HOOKS --------//
		// Hooks are a way to easily add custom functions and content to the Platform theme. There are hooks placed strategically throughout the theme
		// so that you insert code and content with ease.
	
	// HOOKS EXAMPLE --------//
		// Below is an example of how you would add a social media icon to the icons in header (branding section)
		// We have placed a hook at the end of the icon set specifically add new icons without modifying code or having to worry about your edits
		// getting thrown out during the upgrade process. The way to use hooks goes a little like this:
	
		// add_action('hook_name','function name');
	
		// ---> uncomment to load
		add_action('pagelines_branding_icons_end', 'add_icons_to_branding');
	
		// function name
		function add_icons_to_branding(){
			// This hook adds a stumbleupon icon to the header of your theme. The class referenced in the link can be seen in the style.css
			// and is the image from the CSS is placed in the images folder
			?>
	
	
	
	
	
		<?php }
		// end function
	
	
	
	// ABOUT FILTERS ----------//
	
		// Filters allow data modification on-the-fly. Which means you can change something after it was read and compiled from the database,
		// but before it is shown to your visitor. Or, you can modify something a visitor sent to your database, before it is actually written there.
	
	// FILTERS EXAMPLE ---------//
	
		// The following filter will add the font  Ubuntu into the font array $thefoundry.
		// This makes the font available to the framework and the user via the admin panel.
	
	add_filter ( 'pagelines_foundry', 'my_google_font' );
	function my_google_font( $thefoundry ) {
		$myfont = array( 'Ubuntu' => array(
				'name' => 'Ubuntu',
				'family' => '"Ubuntu", arial, serif',
				'web_safe' => true,
				'google' => true,
				'monospace' => false
				)
			);
		return array_merge( $thefoundry, $myfont );
	}
	
	// ADDING NEW TEMPLATES --------//
		// Want another page template for drag and drop? Easy 
		// 			1. Add File called page.[page-id].php to Base
		// 			2. Add /* Template Name: Your Page Name */ and Call to 'setup_pagelines_template();' to that file (see page.base.php)
		// 			3. Add 'pagelines_add_page('[page-id]', '[Page Name]');' to this functions.php file
	
		// Add Base Page
	if ( function_exists( 'pagelines_add_page' ) ) pagelines_add_page('base', 'Custom Page');
	
	// OVERRIDE SECTION TEMPLATES --------//
		// Want more customization control over any of the core section templates in PlatformPro? Just override the template file.
		// To do that, just add a file called template.[section-id].php to this child theme and it will override the section templates
		// for the section with that ID.  For example, template.boxes.php will override the boxes templates.
		// Once overridden you can copy the code from that section, paste it there and edit to your heart's content.
	
	
	[/code]

	
	
	So, I to try and learn a bit more about this all, I tried adding in the default stumble upon icon like this...
	
	
[code] // ABOUT HOOKS --------// // Hooks are a way to easily add custom functions and content to the Platform theme. There are hooks placed strategically throughout the theme // so that you insert code and content with ease. // HOOKS EXAMPLE --------// // Below is an example of how you would add a social media icon to the icons in header (branding section) // We have placed a hook at the end of the icon set specifically add new icons without modifying code or having to worry about your edits // getting thrown out during the upgrade process. The way to use hooks goes a little like this: // add_action('hook_name','function name'); // ---> uncomment to load add_action('pagelines_branding_icons_end', 'add_icons_to_branding'); // function name function add_icons_to_branding(){ // This hook adds a stumbleupon icon to the header of your theme. The class referenced in the link can be seen in the style.css // and is the image from the CSS is placed in the images folder ?> <?php } // end function // add_action('hook_name','function name'); // ---> uncomment to load add_action('pagelines_before_branding_icons', 'add_icons_before_branding'); // function name function add_icons_before_branding(){ // This hook adds a stumbleupon icon to the header of your theme. The class referenced in the link can be seen in the style.css // and is the image from the CSS is placed in the images folder ?> <?php } // end function

This is using the same action that Adam mentions in the hooks tutorial video... add_action('pagelines_before_branding_icons', 'add_icons_before_branding'); However, nothing shows up. This is also using the existing css for the 'stumbleupon' class. What do I need to do to add multiple hooks?

Share this post


Link to post
Share on other sites
kastelic

You can't have two functions with the same name, so the 'add_actions_to_branding" part has to be unique. This part of the function (and the add_action line itselft) is up to you, you can name it whatever you want.

	add_action('pagelines_before_branding_icons', 'google_plus');
	function google_plus(){
	

etc.

Share this post


Link to post
Share on other sites
thomstark
I made all of mine hooks. My code looks like this in the functions.php: // add_action('hook_name','function_name'); add_action('pagelines_branding_icons_end', 'add_icons_to_branding'); // function name function add_icons_to_branding(){?>

Share this post


Link to post
Share on other sites
catrina
You will need to make changes in the following code: [code]// add_action('hook_name','function_name'); add_action('pagelines_branding_icons_end', 'add_icons_to_branding'); // function name function add_icons_to_branding(){?>[/code] You need to change "add_icons_to_branding" to something else because the there can't be two functions with the same name.

Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites
platinum
@kastelic and katrina... thank you for your replies... can you please take a look at the code again, as far as I can see I have added two different function names... [code]function add_icons_to_branding(){[/code] and... [code]function add_icons_before_branding(){[/code] It is hard to spot the difference between the two of them. So am I missing something here? @thomstark... thanks for your reply, what you have posted has helped me to understand a little more, thank you.

Share this post


Link to post
Share on other sites
catrina
function add_icons_before_branding(){ is the hook that is given in the list. It determines where the code will be placed on the site. function add_icons_to_branding(){ is the name of the action you create so that it's easy to identify when you're looking in functions.php file. This name is made up by you, and it cannot be the same as any of the hooks that exist in any of the templates.

Please read the docs before posting. Please do not private message me unless I ask you to.

Designer | Catrina Dulay

Founder | Catrina and Mouse

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×