Jump to content

Module: Blog


kongondo

Recommended Posts

Is it possible to hide the author link shown in the sub-nav sidebar (under the heading See Also)?

I've hidden the author in the post itself from the Settings in the Blog dashboard, but I'd like to do the same in the sidebar (since all posts will be written by the same author so it's rather redundant).

Having looked at the html I see that each sub-nav link is a <li>, but they're not given a unique class or ID so it's hard to target them individually.

All the best,

Tony.

@Tony,

It seems you are using (or copied from) the demo template files that are optionally installed with Blog. In this particular case we are dealing with blog-post.php. The code that generates that sidebar is found between lines 24 - 35. The method spewing out the markup is renderNav() (line #35).  As a quick btw, the general rule of thumb is rather than using CSS to hide markup, first check if it is possible not to output that markup in the first place :-). In our case, it is possible. Line #31 of the code is what is outputting the Author's name and URL. All you need to do is comment out that line, as well as earlier variables building up towards that code, i.e. lines 25 ($authorsURL), 27 ($authorURL) and line 28 ($authorName).

I'm not sure you've seen my earlier posts about documentation (it is a long thread after all), but I used to have Blog's documentation hosted on my website, which is currently in deep hibernation until I get time to revive it. Thankfully, the good guys over at wayback machine archived my now asleep and offline website including all the Blog tutorials. These can be found here and the documentation for renderNav() is here. As you'll see, you can use renderNav() to output all sorts of stuff.

Hope this helps :-)

  • Like 2
Link to comment
Share on other sites

@congomonster,

Sorry this is one of those things that hasn't yet found its way into the documentation. Almost each method in MarkupBlog accepts options to alter its output. For the example you've given, that would be an option in renderComments(CommentArray $comments, $limit = 0, Array $options = null). Within the method, the $defaultOptions are as listed here. The option responsible for 'Post a comment' is 'comments_post_text' => $this->_('Post a comment'), . An example of passing options to the method:

$options = array(
   'comments_post_text' => 'My Text for Post-a-Comment',
   'comments_list_empty' => 'Nobody has dared to comment on this article...yet',
   'comments_empty' => 'Are you sure you want to be the first to comment?'
);

$blog = $modules->get("MarkupBlog");
$renderComments = $blog->renderComments($page->blog_comments, 0, $options);
$content = $blog->renderPosts($page) . $renderComments; 

echo $content;
Link to comment
Share on other sites

Ok. Get it to work  :lol:

I put it in my blog-post.php and changed something looks now like this:

$options = array(
   'comments_post_text' => 'My Text for Post-a-Comment',
   'comments_list_empty' => 'Nobody has dared to comment on this article...yet',
   'comments_empty' => 'Are you sure you want to be the first to comment?'
    );

$renderComments = $blogConfigs['commentsUse'] == 1 ? $blog->renderComments($page->blog_comments, 0, $options) : '';
Link to comment
Share on other sites

Two things:

  1. You never need to change the code in the module itself! Otherwise, your changes would be overwritten with upgrades
  2. You don't need this code to be like this: 
$renderComments = $blogConfigs['commentsUse'] == 1 ? $blog->renderComments($page->blog_comments, 0, $options) : '';

If you read the comments in the demo blog-post.php template file, it says

for this demo, renderComments() has to adapt to whether blog commenting feature was installed or not whilst remaining blog structure/style-agnostic

 in your own blog install, you would know if you enabled the feature so there would be no need for such a check
in addition, our 'check' code is not code you would normally use in a template file. 
we use such code here to be both foolproof that the commenting feature is installed and blog structure-agnostic 

The blog demo could not know in advance whether you or anybody else was going to install Blog with the comments feature enabled/disabled. Hence, it had to make that check by looking into the module configs ($blogConfigs). In your case , you know if you installed blog with the comments feature or not, so no need to make such a check. Hence, use the other code I provided instead, i.e.

$options = array(
   'comments_post_text' => 'My Text for Post-a-Comment',
   'comments_list_empty' => 'Nobody has dared to comment on this article...yet',
   'comments_empty' => 'Are you sure you want to be the first to comment?'
    );

$blog = $modules->get("MarkupBlog");
// Here, no need to check if blog was installed with comments feature; you should know - you installed it yourself 
$renderComments = $blog->renderComments($page->blog_comments, 0, $options);
Link to comment
Share on other sites

Thank you very much! This helps me a lot.

Another question i have is, can i change classes the same way? I searched this topic but didn't find an answer.

For example:

In my blog overview there is

<ul class="MarkupPagerNav">
	<li class="MarkupPagerNavOn MarkupPagerNavFirst MarkupPagerNavFirstNum"><a href="/blog/"><span>1</span></a></li>
	<li class="MarkupPagerNavLastNum"><a href="/blog/page2"><span>2</span></a></li>
	<li class="MarkupPagerNavNext MarkupPagerNavLast"><a href="/blog/page2"><span>Vorwärts</span></a></li>
</ul>

how can i give "MarkupPagerNav" a second class like "pagination". I'm working with Zurb's Foundation Framework.

Link to comment
Share on other sites

Update: Version 2.3.7

Following this question, it is now possible to pass MarkupPagerNav options to renderPosts() if you wish to customise your posts' pagination. All the MarkupPagerNav options listed here can be passed as an array within an array to renderPosts() as shown in the example below:

$blog = $modules->get("MarkupBlog");

$paginationOptions = array(
                'nextItemLabel' => "Forth",
                'previousItemLabel' => "Back",
                'listMarkup' => "<ul class='MarkupPagerNav Zurb pagination'>{out}</ul>",
                'itemMarkup' => "<li class='{class} not necessary class'>{out}</li>",
                'numPageLinks' => 5
);

$options = array(
        'post_pagination' => $paginationOptions,// array of markup pager nav options
        'post_count_text' =>'Article',// other posts options passed as normal
);

echo $blog->renderPosts("limit=5", true, $options); 
  • Like 3
Link to comment
Share on other sites

Hi kongondo,

that's amazing! Thank you for your help. I tried it and it worked when i copy your code.

But i already hav an array for the defaults options. To translate "more" to "mehr" for example.

$content .= $blog->renderPosts("limit=5", true, $defaultOptions);

How can i put the second array behind the $defaultOptions array? I tried google. Is array_merge an option?

Link to comment
Share on other sites

Just like I've shown you in the example above :-). No need to do merges and such. See below (including the comments in the code); hope this is now clearer.

$paginationOptions = array(
                'nextItemLabel' => "Forth",
                'previousItemLabel' => "Back",
                'listMarkup' => "<ul class='MarkupPagerNav Zurb pagination'>{out}</ul>",
                'itemMarkup' => "<li class='{class} not necessary class'>{out}</li>",
                'numPageLinks' => 5
);

$defaultOptions = array(
        //  array of MarkupPagerNav options
        //  you have to use the index 'post_pagination' and its value MUST be an array
        //  here, we've passed it the array $paginationOptions that we created above
        'post_pagination' => $paginationOptions,// the value here must be an array; the index must be named 'post_pagination'
        
        // other stuff you already had in your defaultOptions
        'post_more_text' => 'mehr',
        'post_whatever_option_1' => 'blah blah blah',
        'post_whatever_option_2' => 'foo bar',
);

$content .= $blog->renderPosts("limit=5", true, $defaultOptions);
Edited by kongondo
  • Like 2
Link to comment
Share on other sites

Hi,

i have still some things that i needed to change. Maybe someone knows the answers.

1. After i installed the modul upgrade Processwire says that i have more then one of this modules installed and that i have to choose.

Is this normal?

2. It is possible to add a new entry to the shortcut menu (backend) in Processwire? Blog Category and Blog Tag are already there.

How can i add for example Blog Post?

3. In the Comments section the date is still in english. I changed the date value in blog_date field into german

am %A, den %d.%m.%Y

I tried the same in the field blog_comments. But this doesn't work.

Link to comment
Share on other sites

#1: Not normal. PW version? If you ugraded using PW, it should have renamed the older folder as .ProcessBlog or similar

#3:

A PW date field has two parts. The output and input formats. Have a look at both (input is in the input tab).

  • In the Details tab (Date/Time Output Format Code), you can use your strftime code: am %A, den %d.%m.%Y. You will see that date in the frontend (in your post)
  • In the Input tab (Date/Time Input Formats -> Date Input Format Code) I think you can only use PHP date. So, something like l, d.m.Y in the date input format code will give you Thursday, 11.08.2016. You will see that when editing your post in the backend. You will not be able to uses 'den' with PHP date 
Edited by kongondo
Link to comment
Share on other sites

The Processwire Version is 2.7.0. I have a folder MarkupBlog and a folder called ProcessBlog. There is no folder .Processblog.

I have show hidden files on.

I already changed the entries in the input tab. The format is changeing. But the month stays in english.

Link to comment
Share on other sites

@congomonster, thanks for catching that. Fixed; in dev branch for now. 

@all

Please note that if you want the method MarkupBlog::formatDate() to output your comments date according to the date field in blog_comments, you just need to pass it a second parameter 2 (integer 2). For instance, in the template file 'blog-recent-comments.php', line #30, we had this:

$date = $blog->formatDate($comment->created); 

...but we now have this:

$date = $blog->formatDate($comment->created, 2); 

Since the second parameter is give a value of 1 by default, this change should be backward compatible. Unless you want the updated feature, you don't need to do anything in your template files.

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

Hi kongondo,

I tried out your huge module and I think would like it, but it doesn't work properly (using PW 3.0.7). I will give you a small bug list.

  1. clicking on Posts results in Error: Call to a member function count() on null (line 1355 of .../site/modules/ProcessBlog/ProcessBlog.module.
    Problem: field blog_files isn't assigned to the blog-post template by default which is the reason for the error above.
    After removing line 1355 the modal for posts doesn't appear after clicking, linked page opened instead
  2. The dropdown function of the tabs in Admin are disabled if blog tab is active
  3. cannot open Settings -> Settings -> Edit
  4. cannot open Tags -> New -> Tags Add
  5. cannot open Categories -> New Categories -> Add
  6. cannot open Posts -> Quick Post -> Add
  7. cannot open Edit Posts -> Actions
  8. Dead link (404) in Module description on processwire.com http://kongondo.com/tutorials/specific-features/creating-a-blog-in-processwire/
    (just realized in the topic of this thread a temporarily link to the tutorial)

A personal wish: Dashboard -> Archives -> month clickable with link to a list of selected items

Link to comment
Share on other sites

Hi @kixe I know @kongondo or others will probably be better able to help you but I just wanted to say that the good news is that:

I think would like it, but it doesn't work properly
is incorrect as far as my experience goes—I just installed it on a fresh PW v2.7.3 and it worked perfectly, no errors.
 
To begin to help, perhaps, check you have debug turned on in config.php `$config->debug = true;`, then there is this post.
 
Sorry if you have already done this and good luck; it's worth it, the @kongondo's Module(s) for the blog make a very professional, complete solution. I was greatly impressed when I tried it.
  • Like 1
Link to comment
Share on other sites

@kixe,

Thanks for pointing these out in advance. I am not being naughty but as you can tell from here, Blog is only compatible with ProcessWire 2.4 - 2.7 :P  :-). I have been so busy I haven't even had a chance to install, let alone play with ProcessWire 3.X. 

So for now, I am not able to support Blog for that version of ProcessWire, but I do appreciate people catching such bugs in advance (although, PW 3.X is still an evolving beast) :-)

Edited by kongondo
Link to comment
Share on other sites

Thanks for the quick answer. I am pretty sure your module works proper in 2.7. I am involved in 2 projects both based on 3.0 probably going online in summer. I updated already most of my stuff for 3.0. Ryan is working very very quick and I am pretty sure we will have a stable Version of 3.0 very soon.
 

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
×
×
  • Create New...