Sign in to follow this  

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 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>



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 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.
    • By kongondo
      The Module Blog for ProcessWire replicates and extends the popular Blog Profile.
      Blog is now in version 2.
      Please read the README in the Github link below in its entirety before using this module 
      As of 20 December 2017 ProcessWire versions earlier than 3.x are not supported
      Blog Documentation is here (Work in Progress!)
      See this post for new features in version 2 or the readme in GitHub.
      To upgrade from version 1, see these instructions.
      Most of the text below refers to Blog version 1 (left here for posterity). 
      Blog version 1 consists of two modules:
      ProcessBlog: Manage Blog in the backend/Admin.
      MarkupBlog: Display Blog in the frontend.
      Being a module, Blog can be installed in both fresh and existing sites. Note, however, that presently, ProcessBlog is not compatible with existing installs of the Blog Profile. This is because of various structural and naming differences in respect of Fields, Templates, Template Files and Pages. If there is demand for such compatibility, I will code a separate version for managing Blog Profile installs.
      In order to use the 'Recent Tweets Widget', you will need to separately install and setup the module 'MarkupTwitterFeed'.
      Please read the README in the Github link below in its entirety before using this module (especially the bit about the Pages, etc. created by the module). 
      I'll appreciate Beta testers, thanks! Stable release works fine.
      Modules Directory:
      You can also install from right within your ProcessWire install.
      Screenshots (Blog version 1)

      Video Demos
      Ryan Cramer
      The Alpha Testers and 'Critics' 
    • By dragan
      I'm puzzled by something I thought would be rather easy:
      I want to send a request to a PW page. It's POST, and I define a header, and send data as JSON.
      I need to send data in the following format:
      $ POST {"headers": {"Authorization": "Bearer API_KEY", "Content-Type": "application/json"}, "body": {"fields": {"Name": "<get name>", "Department": "<get team>", "Home Address": "<get address>", "Phone #": "<get phone>", "Personal Email Address": "<get email>", "Birthday": "<get birthday>", "Date Added": "<call>currentDate</call>" }}} This is supposed to be sent via a Chatbot engine (Dexter).
      In the PW page that should handle this, $_POST is always empty, as is $_REQUEST. Same for PW's $input or if ($config->ajax) {}.
      I get the header, but no data.
      So I dug deeper, and tried this:
      @ini_set("allow_url_fopen", true);
      @ini_set("always_populate_raw_post_data", true);
      $data = json_decode(file_get_contents('php://input'), true);
      $d    = print_r($data, true); // I store this, along with the header infos and timestamp in a PW page-field (instead of using file_put_content)
      I checked page permissions, I made sure I use pagename/, i.e. with trailing slash only, to avoid stripping the header away due to redirects (which somebody in an older forum thread once highly suggested).
      I tried to send the same stuff that the chatbot does via CURL. Nothing. PW error logs don't report anything (site is still in dev-mode).
      PW 3.0.81 - everything else runs just fine.
      Any ideas what I should change? Any more PHP/Apache settings maybe?
      Help is highly appreciated.