Sign in to follow this  
rareyush

Blog Post UI

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 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By sam-vital
      Hi,
      I'm creating a News/Updates section for a client and they would like the 3 most recent Updates previewed on the home screen. So this would be Title and Date Posted. These blog posts will be child pages of a News and Updates page, which is a child of the Home page. So it's like Home -> News -> Blog posts. I don't need this to be a nav menu, just something to show the newest updates.
      All help is appreciated 🙂
    • By franciccio-ITALIANO
      Hi, in wordpress homepage we can put a list of LAST ARTICLES AND COMMENTS.
      Can I do same thing with processwire?
      If yes, how?
      There is a tutorial?

      Thanks!
    • By adrian_gp
      Hello everyone,
      I'm new in this forum and my english is not perfect so sorry for the mistakes.
      I have an Blog Project and i will use categories. 
      Here is the structure:
      Blog -> displays all the Blogposts (template=BlogPage) Post-Name -> display the specific Post (template=BlogPost) Categories -> not visible in the menu (template=CategoriesPage) Categorie-Name -> not visible in the menu (template=CategoriePage) For your information:
      (BlogPost) every blogpost has its own page (BlogPost) in Admin i can select the categorie per Field -> SelectMultiple Pages (Checkbox) (fieldname=categories) (Blog) displays all the BlogPosts and all the categories under the ParentTemplate CategoriesPage, which also have their own side Now the Problem:
      On Blog -> I would like to click on a category and only see the post that has this category checked in the BlogPost.
      CategoriePage -> what do I have to insert there to show only the specific posts which use the checked categorie?

      Let me know if you need more information

      Thanks for your support
       
    • By mattcohen
      Hi All, I am wondering if you could provide input on the best way an item as a user favorite.
      I am setting up a price comaprison website, and have most of the logic done for the site. Search results, listing page, login/logout, search, etc. It's all looking pretty good. However someone has suggested to me that users might like to save an item as a favorite.
      So my idea behind that was to have a button on each of the grid items in the search results page. 
      This is my search results page code with the button within the item.
      <form id="add_fav" name="add_fav" autocomplete="off" accept-charset="utf-8" action="./" method="post"> <button class="wish_btn" name="add_fav">Add Fav</button> </form> Where the business logic is on the page, this is what I have so far - I just don't know how to align an item to a user.
      $log->save ('pageview', 'testing'); function clense_input($data){             $data = trim($data);             $data = stripslashes($data);             $data = htmlspecialchars($data);             return $data;         }                 $sort = "title";         // Logic for favorites         if ($_SERVER["REQUEST_METHOD"] == "POST") {           if (isset($_POST['add_fav'])) {             $favs = $sanitizer->text($_POST['add_fav']);             if(!empty($favs)){               $ticket = $pages->get($favs); // Set page name               if($favs != null){                 $favs->of(false);                 $favs->fav_title = $page->user->name; // Save username                 $favs->fav_title = $page->title->id; // Save page id to favs list                 $favs->save();                 echo "Fav saved.";               }             }           }       }  
    • By nickngqs
      I'm trying to create a form that does a post to a php file, getting the values before posting to a database.

      For example a form with an action /controller/add_client.php.
      My current workaround is create a page with the add_client template. But is it possible to do that without creating a page? I.E i do not want it to show on the CMS side.