cmscritic Posted October 23, 2012 Share Posted October 23, 2012 (edited) Fabulous! Worked like a charm, thank you! Actually, one problem is that now it shows: Posts 1 to 1 of 1 at the top of the posts on the home page. Anyways to prevent this? Obviously it's useful on archive pages, search results, etc but not on the home page. See http://thatcriticguy.com(work in progress) to see what I mean. Edited October 23, 2012 by cmscritic Link to comment Share on other sites More sharing options...
WillyC Posted October 23, 2012 Share Posted October 23, 2012 how .about edit /site/templates/markup/posts.php cha.nge if($total) echo "<h3>" . sprintf(__('Posts %1$d to %2$d of %3$d'), $start, $end, $total) . "</h3>"; to if($total && wire('page')->id > 1) echo "<h3>" . sprintf(__('Posts %1$d to %2$d of %3$d'), $start, $end, $total) . "</h3>"; 2 Link to comment Share on other sites More sharing options...
cmscritic Posted October 23, 2012 Share Posted October 23, 2012 You are a legend among men sir! Works perfect, thanks for the quick response and assistance. Link to comment Share on other sites More sharing options...
WillyC Posted October 23, 2012 Share Posted October 23, 2012 or.you could hide w css if you like.better body.template-home #bodycopy > h3:first-child { display: none; } but i like better.to edit posts.php Link to comment Share on other sites More sharing options...
cmscritic Posted October 23, 2012 Share Posted October 23, 2012 or.you could hide w css if you like.better body.template-home #bodycopy > h3:first-child { display: none; } but i like better.to edit posts.php I'm not big on hiding with CSS either, the issue of course being that it executes code unnecessarily. Your solution definitely seems to work without a hitch. Link to comment Share on other sites More sharing options...
ryan Posted October 24, 2012 Author Share Posted October 24, 2012 I should mention that this blog profile is just one approach to ProcessWire templates. This one was intentionally made to explore an entirely different path than what is used in the default profile. The approach is probably different from what you'd see in most ProcessWire sites, but I think it's a good approach for long term scalability, especially when the front-end and back-end development are handled by different people. Though there are also other equally good approaches too. In the blog profile, a common include file (/site/templates/blog.inc) was created to house shared functionality that is used by multiple templates. This file just contains standard PHP functions that the individual templates call upon. For example, the ability to render blog posts (whether full or summarized) is something utilized by several templates in the site. Unlike the basic profile, the blog profile delegates most of the markup/HTML generation to files in /site/templates/markup/. Most of these markup generation files are called upon by functions in that blog.inc file. This is very much like an MVC approach. While I think the approach may not have as much practical value on a smaller site, it does make the output very easy to edit. Most of the decision making happens in in the individual template files. While all the markup/HTML comes from the files in /site/templates/markup/. When you want to make markup changes to common output, the files in /site/templates/markup/ have this profile covered. In my own sites, I usually take a similar approach except without the /markup/ files. I usually bundle the markup generation right into the shared include file (like blog.inc). That makes it simpler for me to maintain, though the blog profile approach would be better when there is a team of people (rather than one developer). Link to comment Share on other sites More sharing options...
digitex Posted November 5, 2012 Share Posted November 5, 2012 Greetings gentle folk of processwire. I wanted to add an insight I had when porting the blog to an existing website. Everything went great with the addition of the blog fields and templates and works like a charm. Once the blog author is logged in he/she can go to the home page and a new contextual menu displays with options to edit a post, add new post, edit profile and such. That menu resides in the "markup" directory within the site templates directory with the name admin.php. The one and only issue I had is with the link to add new post as it's coded with the page id of the posts parent. 1006. When you add the blog to an existing site you can't guarantee the parent page will have the id 1006 though and in fact for me the correct id is 1080. I fixed the link and everything is groovy. I'm only posting this as a head's up to anyone else that might try adding the blog functionality to an existing site. The features are impressive and using it is far easier than building your own from scratch. 4 Link to comment Share on other sites More sharing options...
Michael Murphy Posted November 8, 2012 Share Posted November 8, 2012 Thanks for the profile, I have learnt a lot from exploring it. Is there any reason why there is access permissions set on 5 of the templates? - category - categories - tags - post - widgets Also, I thought the "export profile" module ignored access permissions when creating a profile? Link to comment Share on other sites More sharing options...
ryan Posted November 9, 2012 Author Share Posted November 9, 2012 Is there any reason why there is access permissions set on 5 of the templates? The profile is setup with an "author" role that you can make use of to have non-superuser authors. Those templates that have access definitions are setup to be editable by the "author" role. In this way, the system is multi-author ready. Also, I thought the "export profile" module ignored access permissions when creating a profile? Just users. Roles and permissions can accompany a profile. Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Something I discovered with this profile (which I'm almost done implementing by the way) is that if you insert an image into a post and resize the window, sometimes the image overlaps the right sidebar. I used a neat CSS trick to make my images, regardless of size, automatically resize with the windows. Here is the CSS: img { max-width: 100%; height: auto; width: auto\9; /* ie8 */ } This makes things nice and neat. 1 Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Author Share Posted November 14, 2012 Thanks Mike! Great addition -- I will update the profile to make this change. One thing I wanted to mention about this blog profile. I know that you are evaluating ProcessWire among other CMSs, and wanted to highlight that the Blog profile might not necessarily be the best single place to evaluate ProcessWire from. It's just one application/template approach among many that people use. I think that the Basic profile included with ProcessWire actually does a better job of revealing the inherent simplicity, and path-of-least-resistance, of the template system. Whereas the Blog profile gets into using ProcessWire in a more MVC front-end framework approach. So it was intended not just as a blog profile for people to use, but also as a next-step (from the basic profile) demonstration of a more advanced approach. This is a great approach to use, but I usually get people started with the basic profile before exploring this, and other approaches. I'm guessing you probably know all of this already. But even if this is old news to you, I figured I should also mention this for others that may be reading about the blog profile. Link to comment Share on other sites More sharing options...
Michael Murphy Posted November 14, 2012 Share Posted November 14, 2012 I think there is something wrong with the permission settings (or maybe I have misunderstood how they work). I am testing the Blog profile on a fresh install 2.2.9 If I add a new user with the "author" role, and then log in with that user - they see nothing. All the templates with access permissions, have the "author" role set to view only, and all the other options (edit, create, add) are disabled (basically just like the guest role). You then have to manually adjust the 6 templates (home, category, categories, tags, post, widgets) to allow for author editing. Am I missing something? Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Author Share Posted November 14, 2012 You then have to manually adjust the 6 templates (home, category, categories, tags, post, widgets) to allow for author editing. That's correct, this is how it's setup here. The assumption is that "author" would be a limited access editor that you might only give access to post new blog entries, but feasibly you might give them access to add categories and tags too. So the role is setup and ready for you decide what you want "author" to be able to edit. I would suggest giving author access to edit posts, categories and tags, but not home or widgets. Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Hi Ryan, Don't worry, I know the blog profile doesn't showcase what ProcessWire was intended for. I am primarily using it as a starting point for my personal site, which I've been tweaking steadily. Quick question for you. I implemented these changes that WillyC recommended but the excerpts are now far too small: in /site/templates/home.php, I changed $content = $page->body . renderPosts("limit={$page->quantity}"); to this: $content = $page->body . renderPosts("limit={$page->quantity}", true); Is there a way to perhaps place a <read more> link of some kind in the text editor or limit the # of characters in the post shown as excerpts? The issue is that the excerpt is two lines of text and no pictures. I'm trying to find a happy medium here without showing the entire post on the front page. I'd prefer to capture the first picture in the post and the first paragraph and then have a "continue reading" link. You can see what I'm getting now here: That Critic Guy Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Nevermind. I just figured this out on my own. Apparently, I just needed to change the field "Summary" to allow it to use TinyMCE and remove text formatting and now she works like a charm just like an excerpt field. Did I mention I love ProcessWire? 3 Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Author Share Posted November 14, 2012 Nevermind. I just figured this out on my own. Apparently, I just needed to change the field "Summary" to allow it to use TinyMCE and remove text formatting and now she works like a charm just like an excerpt field. This should work, but one [minor] thing to note is that I've setup that summary field to double as the <meta description>. You could go ahead and just create a new field and call it 'meta_description' (or something like that), or you could continue to use the existing 'summary' field, but you'd want to strip the markup out of it for placement in the meta tag: In /site/templates/main.inc, change this: <?php if($page->summary) echo "<meta name='description' content='{$page->summary}' />"; ?> To this: <?php if($page->summary) echo "<meta name='description' content='" . strip_tags($page->summary) . " />"; ?> (basically you just add the strip_tags). Another minor thing is that the <div class="post-body"> now has doubled <p> tags around that summary. That's because the it was previously assuming that the summary wasn't marked up. Since it is now marked up (TinyMCE), you'll want to do this: In /site/templates/markup/post.php, change this: echo "<p>" . $page->summary . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>"; To this: echo $page->summary . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a>"; (basically just remove the surrounding <p> tag) If you want to have that "View More" link contained within the last paragraph, rather than on a separate line, you could do this (I think… writing in the browser here): echo substr($page->summary, 0, -4) . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>"; Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Nice! Changes made, thanks for pointing that out and yes, the view more within the last paragraph is better. Looks good so far! Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Hm. Something weird seems to have occurred and the CSS on the site appears to be buggered up now. Something in the changes we did? You can see what I mean on http://thatcriticguy.com Oddly, the changes I made seem not to have applied. Let me see if I can figure it out first. Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 Ryan, It looks like the changes we made to /site/templates/main.inc caused the styling on the site to get buggered up. As soon as I reverted that piece, the styling came back. Thoughts? I assume it's a missed closing tag somewhere but I'm not adept enough to know where. Link to comment Share on other sites More sharing options...
Soma Posted November 14, 2012 Share Posted November 14, 2012 Ryan, It looks like the changes we made to /site/templates/main.inc caused the styling on the site to get buggered up. As soon as I reverted that piece, the styling came back. Thoughts? I assume it's a missed closing tag somewhere but I'm not adept enough to know where. Isn't here the opening <p> missing ? echo substr($page->summary, 0, -4) . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>"; Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Author Share Posted November 14, 2012 Isn't here the opening <p> missing ? The opening <p> should already be there since its a TinyMCE field. But if there were any posts still in place that hadn't yet been saved with the new TinyMCE field, then this could account for it. I think the fix would be to go and save all the posts that don't yet have TinyMCE markup. Or account for either possibility in the code: if(strpos($page->summary, '<p>') === 0) echo substr(trim($page->summary), 0, -4); else echo "<p>" . $page->summary; echo "… <a class='more' href='$page->url'>" . __('View More') . "</a></p>"; Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 The opening <p> should already be there since its a TinyMCE field. But if there were any posts still in place that hadn't yet been saved with the new TinyMCE field, then this could account for it. I think the fix would be to go and save all the posts that don't yet have TinyMCE markup. Or account for either possibility in the code: if(strpos($page->summary, '<p>') === 0) echo substr(trim($page->summary), 0, -4); else echo "<p>" . $page->summary; echo "… <a class='more' href='$page->url'>" . __('View More') . "</a></p>"; The changes to the summary work fine, no issues there, but the changes you mentioned for main.inc break the styling on the whole site so there must be something missing in that code? Link to comment Share on other sites More sharing options...
ryan Posted November 14, 2012 Author Share Posted November 14, 2012 Ah sorry I was looking in the wrong place. It looks like I missed a closing quote on that meta tag: Change this: <?php if($page->summary) echo "<meta name='description' content='" . strip_tags($page->summary) . " />"; ?> To this: <?php if($page->summary) echo "<meta name='description' content='" . strip_tags($page->summary) . "' />"; ?> Does that fix it? 1 Link to comment Share on other sites More sharing options...
cmscritic Posted November 14, 2012 Share Posted November 14, 2012 That worked, thank you sir! Now, because I wouldn't want you to think you could stop using your brain for two seconds, I have a new question. I also just tried adding some code for sharethis.com (sharing buttons) but it appears I'm editing the wrong files because I can't get it to work. Their site tells me to add this code at the bottom of the post: <span class='st_sharethis_hcount' displayText='ShareThis'></span> <span class='st_facebook_hcount' displayText='Facebook'></span> <span class='st_googleplus_hcount' displayText='Google +'></span> <span class='st_twitter_hcount' displayText='Tweet'></span> <span class='st_linkedin_hcount' displayText='LinkedIn'></span> <span class='st_email_hcount' displayText='Email'></span> so I assumed I'd add it under this chunk of code in /site/templates/markup/post.php: <div class='post-body'> <?php if($small) { echo substr($page->summary, 0, -4) . "… <a class='more' href='{$page->url}'>" . __('View More') . "</a></p>"; } else { echo $page->body; // if the post has images and no <img> tags in the body, then make it a gallery if(count($page->images) && strpos($page->body, '<img ') === false) include("./gallery.php"); } ?> </div> It then tells me to add this code into my site header: <script type="text/javascript">var switchTo5x=true;</script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher: "c29ec199-09ee-40fc-ae3d-746c240bb69a"});</script> so I edited the file /site/templates/head.inc and put it here: <!-- This website is powered by ProcessWire CMF/CMS. ProcessWire is a free open source content management framework licensed under the GNU GPL. ProcessWire is Copyright 2012 by Ryan Cramer / Ryan Cramer Design, LLC. Learn more about ProcessWire at: http://processwire.com --> <script type="text/javascript">var switchTo5x=true;</script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher: "c29ec199-09ee-40fc-ae3d-746c240bb69a"});</script> </head> This does not appear to work, however, and nothing loads. What am I missing? 1 Link to comment Share on other sites More sharing options...
Crssp Posted January 23, 2013 Share Posted January 23, 2013 Hey just diving in here, the blog profile needs a sort of magazine layout homepage. I guess that may make it a news or magazine profile then maybe. Just a thought, and just jumping it, not having read through the entire thread at all. I love the fact the blog profile is built with the getskeleton.com, Dave Gamache - skeleton css framework. it is very straight foreward and easy to use for general layout purposes. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now