Recommended Posts

Strange. So, what does this return;

$posts = $pages->find('template=blog-post,limit=5,include=all');
echo $posts->count;
// OR asking Tracy
bd($posts);

 

Share this post


Link to post
Share on other sites
1 hour ago, kongondo said:

Strange. So, what does this return;


$posts = $pages->find('template=blog-post,limit=5,include=all');
echo $posts->count;
// OR asking Tracy
bd($posts);

 

The echo returns '1', which is correct. There is one post published.

The TracyDebugger dumps returns a big array which I think is correct too:

ProcessWire\PageArray #71aa
selectors protected => ProcessWire\Selectors #0607
finderOptions protected => array ()
lazyLoad protected => FALSE
keyIndex protected => array (1)
11903 => 0
numTotal protected => 1
numLimit protected => 5
numStart protected => 0
data protected => array (1)
0 => ProcessWire\Page #9d06
extraData protected => array ()
itemsRemoved protected => array ()
itemsAdded protected => array ()
duplicateChecking protected => TRUE
useFuel protected => TRUE
_instanceNum private => 1718
localHooks protected => array ()
trackChanges private => 2
changes private => array ()
_notices protected => array (3)
errors => NULL
warnings => NULL
messages => NULL
_wire protected => ProcessWire\ProcessWire #1005
debug protected => FALSE
fuel protected => ProcessWire\Fuel #4473
data protected => array (29) [ ... ]
lock protected => array (21) [ ... ]
requiredInterfaces protected => array (1) [ ... ]
pathSave protected => ""
instanceID protected => 0
shutdown protected => ProcessWire\WireShutdown #090d
useFuel protected => TRUE
_instanceNum private => 3
localHooks protected => array ()
trackChanges private => 0
changes private => array ()
_notices protected => array (3)
errors => NULL
warnings => NULL
messages => NULL
_wire protected => ProcessWire\ProcessWire #1005 { RECURSION }

EDIT:

I do get an error by TracyDebugger though when I click on the 'Blog' tab in the backend: 

Illegal offset type on line 916 in ProcessBlog.module $posts->title => array('published' => $qn['blog-post'], 'unpublished' => $qn['unpublished'] ),

I can skip the error while everything keeps working. I don't know if that has anything to do with it. Just wanted to let you know.

Share this post


Link to post
Share on other sites
17 minutes ago, Harmen said:

The echo returns '1', which is correct. There is one post published.

Just two things then. If you run the same code without the 'include=all', what do you get? If you still get something, then your post is published. Secondly, do you echo out $content; anywhere?

18 minutes ago, Harmen said:

I do get an error by TracyDebugger though when I click on the 'Blog' tab in the backend: 

It is unrelated and has been on my todo list :-), thanks.

Share this post


Link to post
Share on other sites
13 minutes ago, kongondo said:

If you run the same code without the 'include=all', what do you get?

Nothing. But the page is published, so it should be listed right?

408332055_Schermafbeelding2018-10-04om14_51_00.png.d68270067e75576e1fe7a2839a4f06e5.png

1223336938_Schermafbeelding2018-10-04om14_50_47.png.3fe40eb951896a2a930fef86aedf6b00.png

13 minutes ago, kongondo said:

Secondly, do you echo out $content; anywhere?

Yeah I use $content all the time. I just wanted to list the posts so I could apply my own CSS after the code for the listing is done.

So my blog.php file looks like this now:

<?php namespace ProcessWire;

// CALL THE MODULE - MarkupBlog
$blog = $modules->get("MarkupBlog");

// === Get the limit
$settings = $pages->get('template=blog-settings');
$limit = $settings->blog_quantity;

// === Initialize $content
$content = '';

// Render limited number of posts on Blog Home Page
$content .= $blog->renderPosts("limit=$limit"); // => Returns "No posts found"

// === Code for testing purposes to see the difference
//$posts = $pages->find('template=blog-post,limit=5, include=all'); => Returns 1
$posts = $pages->find('template=blog-post,limit=5'); // => Returns 0
$content .= $posts->count;

$options = array(
    "Breadcrumbs" => true,
);

// === Function to render the whole page, including some options and markup
$content = renderPage($page, $content, $options);

 

Share this post


Link to post
Share on other sites
3 minutes ago, Harmen said:

Nothing. But the page is published, so it should be listed right?

If it returns nothing and the page is published (as we can see from your screenshot), the only thing left is some access control cascading down to your blog template.  Do you just have the one post? Could you create a couple more and test? This one has me stumped to be honest.

 

Share this post


Link to post
Share on other sites

So i've created 3 more posts with some sample content:

1348148196_Schermafbeelding2018-10-04om15_11_34.png.1e728c9c7d962b2ef42d67f3ceac3192.png

The $blog->renderPosts("limit=$limit") function still returns that it can't find any posts. If I add include=all to the line to find the post, then I can find all the posts. IDK what is going on here

 

Share this post


Link to post
Share on other sites

Is the site online?

This works as well?

 $blog->renderPosts("include=all,limit=$limit");

 

Edited by kongondo
  • Like 1

Share this post


Link to post
Share on other sites

Yep, that works. You can visit the blog page here: website

Edited by Harmen
Removed url that was expired

Share this post


Link to post
Share on other sites
On 10/4/2018 at 5:15 PM, kongondo said:

I'm getting a 404 on that page 🙂

Yeah I finally found the culprit. This is a multi-lingual website with up to 9 languages. I guess the module created the pages with only one language enabled to be viewed and I had to click the checkbox for the other pages manually. I should've seen this earlier 😕 Thanks for the great and fast support though. 

Share this post


Link to post
Share on other sites
4 minutes ago, Harmen said:

Yeah I finally found the culprit. This is a multi-lingual website with up to 9 languages. I guess the module created the pages with only one language enabled to be viewed and I had to click the checkbox for the other pages manually. I should've seen this earlier 😕 Thanks for the great and fast support though. 

Glad you got it sorted 🙂

Share this post


Link to post
Share on other sites

 


Hello, let's see if anyone can help me. I'm new to processwire and php, and that's probably the problem.

I am using the module and it works well for me and I understand it. The problem is that I have a template with its corresponding div and styles, and I would like to take comments for a post, for example.

I get show everything with
 

$ blog-> renderComments ($ page-> blog_comments)

But I would like individually the author of the comment, the date, the body. Then with a loop assign it and repeat it as many times as there are comments, and so keep the style of my page.

 

Maybe this is not the right way to do it, but I can not think of another way, if you can help me I'll be very grateful, a greeting

Share this post


Link to post
Share on other sites
1 hour ago, colinosoft said:

But I would like individually the author of the comment, the date, the body. Then with a loop assign it and repeat it as many times as there are comments, and so keep the style of my page.

The blog module uses PW's core Comments field type. You can either use its render() method and pass in templates that generate the desired output, or iterate over the comments yourself and assemble the HTML. All of that is explained in FieldtypeComment's documentation.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, BitPoet said:

The blog module uses PW's core Comments field type. You can either use its render() method and pass in templates that generate the desired output, or iterate over the comments yourself and assemble the HTML. All of that is explained in FieldtypeComment's documentation.

Thank you very much, just what I needed, now I have everything much more clear, thank you.

Share this post


Link to post
Share on other sites
20 hours ago, BitPoet said:

The blog module uses PW's core Comments field type. You can either use its render() method and pass in templates that generate the desired output, or iterate over the comments yourself and assemble the HTML. All of that is explained in FieldtypeComment's documentation.

 

Ok I almost have it, the only thing I can not do is style the form to leave comments, the textbox and the send button do not just take the style of my page. If you can help me, I would greatly appreciate it, greetings.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By anderson
      Hi all,
      I'm a new to website building. Learned some CRASH course of js,jquery,php. Then I found CMS. Still learning around forum, youtube....
      Anyway, please help me with some beginer questions:
      1, About template - please correct me if I understand wrong : every page should be (or recommended) built on a template. So if in total I'll have 10 pages, 2 of them have same layout, I'll need 9 templates.  And, what fields a page includes, is not defined in page, but defined in the template that page uses. 
      2,  Where to see what modules I've installed? is it in "Modules - Site"? 
      3, I installed "PageTable Extended", then what?  As in a youtube tutorial, it should appear in Setup tab, but it doesn't.  What's in there: templates,fields,logs,comments. (I installed "Uikit 3 site_blog profile".)
      4, I did a search in Processwire website for the famous "repeater matrix" module, and can not find it, there's a Repeater, as well as a Matrix. Is it not a module?
      5, I watched this youtube tuts: https://www.youtube.com/watch?v=IHqnLQy9R1A
      Anybody familiar with this tuts please help: 
      After he analysed a target webpage layout he wanted to mimic, he created some fields, some template, then based on those he created a page and input some "content" in there, then clicked "view", it's just some text. So, here comes my question, he copied a folder "assets" (subfolders are: css,fonts,js,img) over, then the page have the appearance/layout he wanted to mimic. Where does that assets folder come from?
      Appreciate any help.
    • By mtwebit
      I've created a set of modules for importing (manipulating and displaying) data from external resources. A key requirement was to handle large (100k+) number of pages easily.
      Main features
      import data from CSV and XML sources in the background (using Tasker) purge, update or overwrite existing pages using selectors user configurable input <-> field mappings on-the-fly data conversion and composition (e.g. joining CSV columns into a single field) download external resources (files, images) during import handle page references by any (even numeric) fields How it works
      You can upload CSV or XML files to DataSet pages and specify import rules in their description.
      The module imports the content of the file and creates/updates child pages automatically.
      How to use it
      Create a DataSet page that stores the source file. The file's description field specifies how the import should be done:
      After saving the DataSet page an import button should appear below the file description.

      When you start the import the DataSet module creates a task (executed by Tasker) that will import the data in the background.
      You can monitor its execution and check its logs for errors.

      See the module's wiki for more details.
      The module was already used in three projects to import and handle large XML and CSV datasets. It has some rough edges and I'm sure it needs improvement so comments are welcome.
    • By dreerr
      TemplateEnginePug (formally TemplateEngineJade)
       
      This module adds Pug templates to the TemplateEngineFactory. It uses https://github.com/pug-php/pug to render templates.
      doctype html html(lang='en') head meta(http-equiv='content-type', content='text/html; charset=utf-8') title= $page->title link(rel='stylesheet', type='text/css', href=$config->urls->templates . 'styles/main.css') body include header.pug h1= $page->title if $page->editable() p: a(href=$page->editURL) Edit Project on GitHub: github.com/dreerr/TemplateEnginePug
      Project in modules directory: modules.processwire.com/modules/template-engine-pug/
       
      For common problems/features/questions about the Factory, use the TemplateEngineFactory thread.
       
    • By Robin S
      Pages At Bottom
      Keeps selected pages at the bottom of their siblings.
      A "bottom page" will stay at the bottom even if it is drag-sorted to a different location or another page is drag-sorted below it (after Page List is refreshed the bottom page will still be at the bottom).
      Newly added sibling pages will not appear below a bottom page.
      The module also prevents the API methods $pages->sort() and $pages->insertAfter() from affecting the position of bottom pages.
      Note: the module only works when the sort setting for children on the parent page/template is "Manual drag-n-drop".
      Why?
      Because you want some pages to always be at the bottom of their siblings for one reason or another. And someone requested it. 🙂
      Usage
      Install the Pages At Bottom module.
      Select one or more pages to keep at the bottom of their siblings. If you select more than one bottom page per parent then their sort order in the page list will be the same as the sort order in the module config.

       
      https://github.com/Toutouwai/PagesAtBottom
      https://modules.processwire.com/modules/pages-at-bottom/
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/