edit layout-blog.php or suffusion_after_begin_post()?

General questions pertaining to how certain issues can be resolved. This forum is closed with effect from February 2019. Please post future requests on https://github.com/sayontan/suffusion.
Forum rules
This forum is closed with effect from February 2019. Please post future requests on https://github.com/sayontan/suffusion.

1. No offensive language and no mocking
2. Please do a thorough search before you post something. Trust us, there is a high probability that the question you are asking has been asked previously.
3. No soliciting. You cannot post here soliciting bids for people offer you quotes, or even offer money to people for some work. You will be moderated if you do so. If you are looking for help, please post your request on http://jobs.wordpress.net or http://codepoet.com
4. Please be reasonable. You are getting software and support. For free. Complicated requests from a general purpose theme are not welcome and some volunteers might lose patience with you.
5. Please do your due diligence. If you posted a query and we answered with a link, take the trouble to go through the link contents.
6. Please post with complete information. Requests for help MUST be accompanied with your URL, particularly if you are asking something like "Why am I seeing a blank space?"
Locked
halifaxious
Posts: 6
Joined: 10 Mar 2011, 07:01

edit layout-blog.php or suffusion_after_begin_post()?

Post by halifaxious » 05 Jul 2011, 07:42

Hi,

I'm using Suffusion 3.8.0. I've created a child theme (ASH) and added a few custom post types in the ASH `functions.php` file. I also created a few `single-customposttype.php` template files. All these work. But, I'm running into difficulties creating a child version of `layouts/layout-blog.php`.

First, will Suffusion use `ASH/layouts/layout-blog.php`, or will it insist on using it's own version? I want to make sure my modifications aren't clobbered by future Suffusion releases.

Second, because my custom post types have multiple custom fields and in some cases custom taxonomies (which is why I declared them in `ASH/functions.php` rather than using the Suffusion form), Suffusion does not seem to want to display them with the usual date box and background. Below is the HTML for a normal post and a custom post. As you can see, the 'title-container fix' div is missing from the custom post as is the 'title' div

Normal post

Code: Select all

<div id="post-514" class="post-514 post type-post status-publish format-standard hentry category-news tag-magazine">
		<div class="title-container fix">
			<div class="title">
				<h2 class="posttitle"><a title="Farewell FiberArts" rel="bookmark" class="entry-title" href="http://ashguild.ca/archives/514">Farewell FiberArts</a></h2>
				<div class="postdata fix">
		<span class="author">
	Posted by <a href="http://ashguild.ca/archives/author/wslandry">Wendy Landry</a> at 7:48 pm</span>
				</div><!-- /.postdata -->
			</div><!-- /.title -->
			<div class="date"><span class="month">Jun</span> <span class="day">26</span><span class="year">2011</span></div>
		</div><!-- /.title-container -->
	<div class="entry-container fix">
		<div class="entry entry-content fix">
<p>It has just come to my attention that Fiberarts Magazine, published by Interweave Press, is closing after some 30 years of service to textile afficionados. &nbsp;For more information, go to the Fiberarts website, http://www.fiberarts.com/. &nbsp;This link will provide details of how to obtain past articles. &nbsp;The Summer 2011 is the final issue; buy a copy <a href="http://ashguild.ca/archives/514">[...]</a></p>
		</div><!--entry -->
	</div><!-- .entry-container -->
	<div class="post-footer fix">
				<span class="tags">Tagged with: <a rel="tag" href="http://ashguild.ca/archives/tag/magazine">magazine</a><br></span>
	</div><!-- .post-footer -->
	</div>
Custom post

Code: Select all

<div id="post-564" class="post-564 ash_spinning type-ash_spinning status-publish format-standard hentry">
		<h2 class="posttitle"><a title="test spinning sample" rel="bookmark" class="entry-title" href="http://ashguild.ca/archives/ASH_spinning/test-spinning-sample-3">test spinning sample</a></h2>
        <div class="postdata fix">
		        </div>
	<div class="entry-container fix">
		<div class="entry entry-content fix">
		</div><!--entry -->
	</div><!-- .entry-container -->
	<div class="post-footer fix">
				<span class="tags"></span>
	</div><!-- .post-footer -->
</div>
So, should I put a conditional in `ASH/layout-blog.php` that detects the post type and uses different output functions for my custom posts? Or, should I extend the `suffusion_after_begin_post()` and `suffusion_content()` functions so they know what to do with my custom posts? I think I'd prefer the latter but I'm not really clear how to go about it.

Perhaps something like:

Code: Select all

add_action('suffusion_after_begin_post','ASH_after_begin_post');
function ASH_after_begin_post(){
  //what should go here?
}
Any thoughts?

Thanks,
Jen, http://ashguild.ca

sayontan
Site Admin
Posts: 10210
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas
Contact:

Re: edit layout-blog.php or suffusion_after_begin_post()?

Post by sayontan » 05 Jul 2011, 08:12

First, will Suffusion use `ASH/layouts/layout-blog.php`, or will it insist on using it's own version? I want to make sure my modifications aren't clobbered by future Suffusion releases.
The child theme's file will be used.
So, should I put a conditional in `ASH/layout-blog.php` that detects the post type and uses different output functions for my custom posts? Or, should I extend the `suffusion_after_begin_post()` and `suffusion_content()` functions so they know what to do with my custom posts? I think I'd prefer the latter but I'm not really clear how to go about it.
You should extend suffusion_after_begin_post. Note that the actual function that prints the title-container etc is suffusion_print_post_page_title (in actions.php), which is hooked into suffusion_after_begin_post. That function explicitly checks the post type. You can use this function as a boilerplate for ASH_after_begin_post.

halifaxious
Posts: 6
Joined: 10 Mar 2011, 07:01

Re: edit layout-blog.php or suffusion_after_begin_post()?

Post by halifaxious » 05 Jul 2011, 10:58

Thanks for the advice. I'm attempting what you suggested and I'm running into a problem of duplicate posts because I want to use the usual `suffusion_print_post_page_title()` function when the post type is not one of a defined set. This is what I'm trying:

Code: Select all

add_action('suffusion_after_begin_post','ASH_print_post_page_title');

function ASH_print_post_page_title() {
	global $post, $suf_page_show_comment, $suf_page_show_posted_by, $suf_page_meta_position;
	if (!preg_match("/^ash/i",$post->post_type)) {
		return; //use Suffusion unless it's a custom post type
	} else {
		echo $post->post_type; //debugging check to see if ASH function is being used
	}

//copied from suffusion version
	$format = suffusion_get_post_format();
//...
	$post_with_title_show_perm = $$with_title_show_perm;
//start ASH code

	$header_tag = (is_singular()) ? "h1": "h2";

	if('ash_weaving'==$post->post_type){
		//do something
	}else if ('ash_dyeing'==$post->post_type){
		//do something
	} else if ('ash_loomsong'==$post->post_type){
		//do something
	}else if('ash_spinning'==$post->post_type){

//currently, the rest of ASH function same as suffusion function except only applied to post type 'ash_spinning'
//...
How do I tell 'suffusion_after_begin_post()' to not use 'suffusion_print_post_page_title` unless ASH_print_post_page_title is inappropriate? I tried this:

Code: Select all

remove_action('suffusion_after_begin_post','suffusion_print_post_page_title');
add_action('suffusion_after_begin_post','ASH_print_post_page_title');

function ASH_print_post_page_title() {
	global $post, $suf_page_show_comment, $suf_page_show_posted_by, $suf_page_meta_position;
	if (!preg_match("/^ash/i",$post->post_type)) {
		return suffusion_print_post_page_title(); //just causes post to print twice even though remove_action should prevent it (I think)
	} 
//...
}
But, for some reason the `remove_action()` has no effect. It appears that with or without remove_action, 'ASH_print_post_page_title' runs and then 'suffusion_print_post_page_title' runs. I am flummoxed. What is wrong with my logic?

Thanks,
Jen

sayontan
Site Admin
Posts: 10210
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas
Contact:

Re: edit layout-blog.php or suffusion_after_begin_post()?

Post by sayontan » 05 Jul 2011, 12:04

Ah, the perennial race problem. This is what you should do:
1. In functions.php add:
add_action("after_setup_theme", "ash_theme_setup", 11);
2. Put your add_action and remove_action calls in a new function called ash_theme_setup. The third parameter in the line above will ensure that your hook will be invoked after Suffusion's.

callmeandy
Posts: 41
Joined: 15 Jun 2012, 19:33
Contact:

Re: edit layout-blog.php or suffusion_after_begin_post()?

Post by callmeandy » 18 Jul 2012, 08:09

Slightly different section of the layout but I am looking to overide building breadcrumbs with the Yaost Wordpress SEO plugin.
I have taken note about what was said about the the perennial race problem but I have obviously got something wrong, remove_action still not working. Can anyone help please?
suffusion_child\functions.php contains

Code: Select all

...
remove_action('suffusion_before_begin_content','suffusion_build_breadcrumb');
add_action('suffusion_before_begin_content','AB_build_breadcrumb', 15);
...
// New breadcrumb functionality
function AB_build_breadcrumb() {
     // remove_action('suffusion_before_begin_content','suffusion_build_breadcrumb'); *** tried it here as well
    if ( function_exists('yoast_breadcrumb') ) {
        yoast_breadcrumb('<p id="breadcrumbs">','</p>');
    }
}
It doesnt work in either position - in both instances I get a duplicate row of Breadcrumbs, one suffusion version and one yaost version.

callmeandy
Posts: 41
Joined: 15 Jun 2012, 19:33
Contact:

Re: edit layout-blog.php or suffusion_after_begin_post()?

Post by callmeandy » 19 Jul 2012, 14:57

Ignore the need for an answer on this, although it doesnt naswer the "remove_action" failing, hadnt relaised I could turn them off in the Theme admin panel.

Locked