Jump to content

Blog Profile


ryan

Recommended Posts

The blog profile is meant to be roughly equivalent to what you get with a default WordPress install, but of course there are all kinds of possibilities with how it could be taken further. But the intention really is to keep it as a useful starting point, though I'd be happy to see new profiles built that extend it. 

Link to comment
Share on other sites

Thanks Ryan, where would a person dive in as far as documentation on extending the blog profile, a child profile if you will.

This thread is probably the closest. But the blog profile is nothing more than common PHP and ProcessWire API usage, so pretty much everything PHP or ProcessWire related in terms of documentation will be relevant. The ProcessWire API cheatsheet is one of the best resources as well. 

Link to comment
Share on other sites

  • 2 weeks later...

Hi Ryan.

I installed the blog profile for someone else and of course, for set up and troubleshooting I have a superuser role for myself. I'm the kingmaker though and not the king and I'm never going to write a blog on this particular site (or anywhere probably) but when I go the the authors page I see my username. I didn't give myself the author role and I don't want anyone seeing my username on the site. It's someone else's personal blog and might lead to confusion. So..

I looked into the authors.php template and found:

$authorRole = $roles->get('author');
$superuserRole = $roles->get('superuser');
$authors = $users->find("roles=$authorRole|$superuserRole, sort=title");

on line 33- 35 which explains it. I'm wondering now, is it as simple as removing that and leaving:

$authorRole = $roles->get('author');
$authors = $users->find("roles=$authorRole, sort=title");

or would that create new problems. I read up on this thread and couldn't find anything on this situation, unless I missed it.

  • Like 1
Link to comment
Share on other sites

@digitex I'm pretty sure that you have solved the problem for your use case. Can't see that causing any other issues, but I'm sure Ryan will confirm or correct that.

(In PW it usually is as simple as that :) )

  • Like 1
Link to comment
Share on other sites

@digitex I'm pretty sure that you have solved the problem for your use case. Can't see that causing any other issues, but I'm sure Ryan will confirm or correct that.

(In PW it usually is as simple as that :) )

Thanks Dave. I suspect it is fine to do as well. I saw a line further down that goes something like this (paraphrasing, if one can actually do that with PHP):

if !$author->isSuperuser()

And while that's unrelated it made me think that if the $superuserrole variable is being used elsewhere, taking out the code that defines that variable would likely throw a fatal error and the site's live so I thought I'd get a more expert opinion than my own.

Luckily, it doesn't take long to realize there's an error and put things back as they were so I'll see what happens.

Thanks again.

EDIT: It seems fine. Don't know why I was worried. Cheers.

Link to comment
Share on other sites

  • 3 weeks later...

Just testing out the blog at http://untye.com.s164110.gridserver.com/

I'm getting the following error when attempting a new post.

Can't save page 0: /blog-post/: It has no parent assigned

The url on the post page is:

http://untye.com.s164110.gridserver.com/processwire/page/add/?parent_id=1006

The url on the error page is:

http://untye.com.s164110.gridserver.com/processwire/page/add/

To repro:

  • Logged in as an administrator
  • Go to website home page
  • Click on "Add new post"
  • Add text to the post fields
  • Choose basic-page template( all that is available)
  • Click on "Save"

This is a new install. 

Thanks,

Rick

Link to comment
Share on other sites

 I noticed that this is only half of the blog profile. It looks like this is actually the default site profile with the blog profile templates. This could be problematic, because this is a mashup of two different profiles that weren't meant to go together. To be honest, I'm surprised that anything works at all. :) I suspect that this has got to be the problem.

Link to comment
Share on other sites

  • 3 weeks later...

I'd like to add the blog profile onto this site: avon representative probably as a subfolder. The main site has the standard PW installation v2.2 on the public_html root as usual. If I want to add a blog as a subfolder to public_html and have the layout very similar to the main site, do I just install the PW blog on the subfolder or would it be best to have the blog profile on the main site and style it like the exisiting main site.

I'm looking for recommendations and the best way to do it with minimum man hours. Thanks.

BTW I'm glad you have used the skeleton framework on the blog profile, I like it very much.

Link to comment
Share on other sites

If I want to add a blog as a subfolder to public_html and have the layout very similar to the main site, do I just install the PW blog on the subfolder or would it be best to have the blog profile on the main site and style it like the exisiting main site.

The blog profile is a self running site profile, so it's not something that you can take and install on an existing site. In your case, you'll probably want to install in a subdirectory and then modify it to look like your main site. Though keep in mind it's not particularly difficult to produce blog functionality on your own, so you might also just consider not using the blog profile and instead coding what you need into your main site. 

Link to comment
Share on other sites

there was a post, can't find it now, where someone added the blog profile to an existing site; though i agree it will be easier to just 'roll your own' blog, the way you want, and there is some reusable code in the blog profile that should speed up things like categories, RSS , etc.

Link to comment
Share on other sites

Do you know of any posts that might be helpful if I want to add the coding to existing site?

There really isn't a lot of code involved. But you might find it helpful to look at these files, which is basically what boils it all down: 

  • /site/templates/blog.inc - shared functions for finding and rendering posts, comments, and navigation.
  • /site/templates/markup/*.php - view (output) files used by the functions in blog.inc 

Everything else in the profile calls upon those functions, which is what you would want to do when using the blog profile code in an existing site. 

Link to comment
Share on other sites

Gabi, this one's a bit tricky as PW does not maintain accessible information about the original page when another page gets rendered - which is what happens when showing the Recent Posts widget. So, as it is, the widget does not know which page it's being shown on and thus can't exclude that page from the list. See Ryan's comment here on a very similar question.
 
In that other thread there's a general solution (via a module) to make the original page accessible. To solve this particular case you don't necessarily need a module though, but you can do the very same thing right before rendering the widgets, here (site/templates/main.inc, line 138), like this:

Wire::setFuel('originalPage', $page);

After this you can exclude the original page from the list by modifying the selector here (site/templates/widget-recent-posts.php, line 14), like this:

$originalPage = Wire::getFuel('originalPage');
$posts = $pages->find("template=post, id!=$originalPage, sort=-date, start=0, limit=$limit");

I haven't tested this but I'd say it should work. :)

  • Like 1
Link to comment
Share on other sites

Another way to accomplish it is to have the template calling $page->render(); stuff the $originalPage into $page. In this case, /site/templates/main.inc:

<div class='widgets'><?php

  // render widgets
  $widgets = $page->widgets;
  if(!$widgets || !count($widgets)) $widgets = $homepage->widgets;
  foreach($widgets as $widget) {
    $widget->originalPage = $page; // ADD THIS LINE
    echo "<div class='widget'>" . $widget->render() . "</div>";
  }

?></div>

Then in widget-recent-posts.php:

$posts = $pages->find("template=post, id!=$page->originalPage, sort=-date, start=0, limit=$limit");
  • Like 1
Link to comment
Share on other sites

Oh, nice one. Thank you.

I do have to read more about OOP.

Right now I feel somewhat dizzy because of the posibilities of ProcessWire. Decision block, all that stuf :lol:.

One more question, if you don't mind: what are the benefits of defining widgets as pages/templates instead of, let's say, using some functions included in the template file?

Other than the posibility to alter the item count or the widgets' position/presence on a per page basis.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...