Set the title of a blog post below the featured image

A little QuickTip for everyone who wants to have the blog title below the featured image.

Currently you can only change the order of author, date, featured image and content in the blog tag.

Okay here are my changes:

Go to pulscore/tags/blog_content_loop.php around line 111

Now change this:

$item_html .= "<div class='grid-item blog-wrap blog-entry blog-list-entry'>\n";
$item_html .= "<div class='blog-item-grid'>\n";
# $item_html .= "<h2 class='blog-item-grid-item blog-title blog-entry-title'><a href=\"{$GLOBALS['path']}/{$blog_prefix}-".\strtolower($url_title).\"">{$value->title}</a></h2>\n";
$item_html .= "<h2 class='blog-item-grid-item blog-title blog-entry-title'><a href=\"{$GLOBALS['path']}/{$value->relative_url}\">{$value->title}</a></h2>\n";

# split the layout
$splitted = \explode(' ', $layout);

$deep_html = '';

	foreach ($splitted as $ttt) {

			if        ($ttt == '{{blog-item-author}}') {
				$deep_html .= $helper_author->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";

			} else if ($ttt == '{{blog-item-content}}') {
				$deep_html .= $helper_content->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";

			} else if ($ttt == '{{blog-item-date}}') {
				$deep_html .= $helper_date->generate_html( array('blog_item' => $value, 'format' => \pulsecore\wedge\config\get_json_configs()->json->date_format), $tag_runner_context );
				$deep_html .= "\n";

			} else if ($ttt == '{{blog-item-featured-image}}') {
				$deep_html .= $helper_featured->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";

			} else if ($ttt == '{{blog-item-tag}}') {
				$deep_html .= $helper_tag->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";
			}
		}

To this:

// $item_html .= "<div class='grid-item blog-wrap blog-entry blog-list-entry'>\n";
// $item_html .= "<div class='blog-item-grid'>\n";
// # $item_html .= "<h2 class='blog-item-grid-item blog-title blog-entry-title'><a href=\"{$GLOBALS['path']}/{$blog_prefix}-".\strtolower($url_title).\"">{$value->title}</a></h2>\n";
// $item_html .= "<h2 class='blog-item-grid-item blog-title blog-entry-title'><a href=\"{$GLOBALS['path']}/{$value->relative_url}\">{$value->title}</a></h2>\n";
		
# split the layout
$splitted = \explode(' ', $layout);
		
$deep_html = '';
		
foreach ($splitted as $ttt) {
			
			if        ($ttt == '{{blog-item-title}}') {
				$deep_html .= "<div class='grid-item blog-wrap blog-entry blog-list-entry'>\n";
			    $deep_html .= "<div class='blog-item-grid'>\n";
				$deep_html .= "<h2 class='blog-item-grid-item blog-title blog-entry-title'><a href=\"{$GLOBALS['path']}/{$value->relative_url}\">{$value->title}</a></h2>\n";
			
			} elseif   ($ttt == '{{blog-item-author}}') {
				$deep_html .= $helper_author->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";
				
			} else if ($ttt == '{{blog-item-content}}') {
				$deep_html .= $helper_content->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";
				
			} else if ($ttt == '{{blog-item-date}}') {
				$deep_html .= $helper_date->generate_html( array('blog_item' => $value, 'format' => \pulsecore\wedge\config\get_json_configs()->json->date_format), $tag_runner_context );
				$deep_html .= "\n";
				
			} else if ($ttt == '{{blog-item-featured-image}}') {
				$deep_html .= $helper_featured->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";
				
			} else if ($ttt == '{{blog-item-tag}}') {
				$deep_html .= $helper_tag->generate_html( array('blog_item' => $value), $tag_runner_context );
				$deep_html .= "\n";
			}
		}

As you can see I only copied the upper part (comment or delete), pasted it into the loop and changed it a bit.

Now we can use the tag <<blog-item-title>>

In my blog page the whole thing looks like this:

{{blog:"":"[[blog-content-loop(<<blog-item-featured-image>> <<blog-item-title>> <<blog-item-author>> <<blog-item-date>> <<blog-item-content>>)]]}}

But careful, this version has no fallback, missing the new title tag in the blog tag will break the layout. I can live with it :wink:
Oh yes and maybe save the file, after an update the whole thing is gone again.


3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Thanks again @Oliver for this side :slight_smile:

The Pulse Blog loop layout now has this included from version 5.3.2:

  • Added a blog-item-title tag to the Blog loop layout, so that can be moved around. That means the blog tag now needs parameters if the layout needs to change.

The blog tag has become:

{{blog:"blog":"[[featured-image]] [[blog-content-loop(<<blog-item-author>> <<blog-item-date>> <<blog-item-featured-image>> <<blog-item-title>> <<blog-item-content>>)]]"}}

Notice it’s the <<blog-item-title>> part :slight_smile:

1 Like