Jump to content

Blog Post UI


rareyush
 Share

Recommended Posts

I am using this function to get blogpost but I don't see what's wrong in it and why it is now showing anything in frontend.

 

function ukBlogPost(Page $page, $options = array()) {
	
	$defaults = array(
		'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect)
		'metaIcon' => 'info',
		'moreIcon' => 'arrow-right',
		'moreText' => __('Read more'), 
		'categoryIcon' => 'hashtag',
		'bylineText' => __('Posted by %1$s on %2$s'), 
	);

	$options = _ukMergeOptions($defaults, $options);
	$title = $page->title;
	$img = $page->images->first();
	$date = $page->date ? $page->date : $page->createdStr;
	$name = $page->createdUser->name; 
	$body = summarizeText($page->get('body'), 100);
	$metaIcon = ukIcon($options['metaIcon']);
	$moreIcon = ukIcon($options['moreIcon']);
	$categoryIcon = ukIcon($options['categoryIcon']);
	$n = $page->comments->count();
	$numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : "";
	$itn = $page->get('itineraries');
	
	$ito = $itn->each( "<h4> {itineraries_title}</h4> <p>{itineraries_details} </p> ");

	if($options['summarize'] === null) {
		// auto-detect: summarize if current page is not the same as the blog post
		$options['summarize'] = page()->id != $page->id;
	}
	
/*	$categories = $page->categories->each($categoryIcon . 
		"<a class='uk-button uk-button-text' href='{url}'>{title}</a> "
	);*/

	if($options['summarize']) {
		// link to post in title, and use just the first paragraph in teaser mode
		$title = "<a href='$page->url'>$title</a>";
		$body = explode('</p>', $body); 
		$body = reset($body) . ' ';
		$body .= "<a href='$page->url'>$options[moreText] $moreIcon</a></p>";
		$class = 'blog-post-summary';
	} else {
		$class = 'blog-post-full';
	}

	if($options['summarize']) {
		$heading = "<h4 class='uk-margin-remove tour-heading'>$title</h4>";
	} else {
		$heading = "<h3 class='uk-article-title uk-margin-remove tour-heading'>$title</h3>";
	}
	
	$byline = sprintf($options['bylineText'], $name, $date); 
	
	if($img) {
		$img = $img->size(375,380);		
	}
	
	// return the blog post article markup
	return "

	<div>	
	<div class='uk-card'>
    	<div class='uk-inline-clip uk-transition-toggle'>
       	<img src='$img->url' alt='$img->description' class='uk-border-rounded uk-transition-scale-up uk-transition-opaque' > 
       	 <div class='uk-overlay uk-light uk-position-bottom'>
        			<p class='uk-text-light'>$heading</p>
   		 </div>     
    	</div>
   
      $ito
	</div>
	</div>
	
	";	
}

 

 

I tried running $title, $img etc. - or are they all blank? simultaneously but nothing returns anything.

 

I do not know why it is not working 

Link to comment
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
 Share

×
×
  • Create New...