Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/01/2012 in all areas

  1. I'm leaving tomorrow for vacation and going to be offline all next week. I've got friends staying at my place to keep the business running and cats happy, but during that time you may not see any posts, tweets or commits from me. Just wanted to explain ahead of time so nobody thinks I've disappeared. Though if internet access presents itself, then this will be the first place I'll check in, but just wanted to provide adequate notice if that didn't happen. I'm taking the laptop with me and hope to get some PW updates done on the road as well. If you don't mind, please keep an eye on this place while I'm gone. If any new users drop by here, make them feel at home. Hope you all have a great week next week. Thanks, Ryan
    4 points
  2. Welcome to the forums stardog. Those are all very easy and basic stuff for Processwire. I'll translate your pseudo-tag examples to php (which PW uses as template language also): <PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending"> <li><PW:title/></li> </PW> foreach ($pages->find("template=blog-post, limit=10, sort=-created") as $p) { echo "<li>$p->title</li> } <PW:ShowStuffFromThisPage page="portfolio" limit="4" sort="descending"> <PW:title/> <PW:image/> </PW> foreach ($pages->find("template=portfolio-item, limit=4, sort=-created") as $p { echo $p->title; echo "<img src='{$p->image->url}' alt='' />"; } <PW:ShowStuffFromThisPage page="blog" limit="10" sort="descending"> <div class="blog-post"> <h2><PW:title/></h2> <PW:body/> </div> </PW> Since blog-posts are probably children of "blog" page, then no need for template checking on selector: foreach($page->children as $p) { if ($p == $page->children->first()) $class = 'first'; //this is for differentiation of the first post else $class = ''; echo "<div class='blog-post $class'>"; echo "<h2>$p->title</h2>"; echo $p->body; echo "</div>"; }
    1 point
  3. One more option for this: http://starfishmod.github.com/jquery-oembed-all/
    1 point
  4. Marc, when you are developing a site it's good to turn debug mode on. This will ensure that errors are sent to the screen, exceptions reported, etc. This can be found in /site/config.php. By default, it is false. You'll want to change it to true: $config->debug = true; Obviously you don't want this enabled for production sites, so remember to change it back to false for live/production sites. I don't see any problem with using var_dump, var_export, print_r, etc. so long as you are directing that output to where you can see it. Also avoid running these functions on PW objects as you may get into an infinite loop. Sometimes it can be difficult to track the output of these functions because PW performs a redirect after most POSTs. But if you use PW's built-in reporting functions, they will get queued between requests until they are output. Here are the relevant functions bellow. They will produce the messages that you see at the top of your screen in PW admin: $this->message("status message"); $this->message("status message that only appears in debug mode", Notice::debug); $this->error("error message"); $this->error("error message that only appears in debug mode", Notice::debug); If you are outside of a Wire derived object, you can call upon any API var to handle the notice for you. For example: wire('session')->message('status message'); wire('pages')->error('error message'); Note that these reporting functions above are for the admin (and related modules), and they don't do anything on the front-end of your site. How you choose to debug or report errors on the front-end is at your discretion. Personally, I keep debug mode on in development, and this puts PHP into E_ALL | E_STRICT error reporting mode... it reports everything possible. If I need to examine the value of something on the front-end, I'll do it the old fashioned way with just PHP. Though others may prefer to go further with their debugging tools. If you want to keep your own error log, here's how (anywhere in PW): $log = new FileLog($config->paths->logs . 'my-log.txt'); $log->save('whatever message you want'); You can direct it to store logs wherever you want, but I suggest using the PW logs dir as shown in the example above. This will make the log appear in /site/assets/logs/, and this directory is not web accessible for security.
    1 point
×
×
  • Create New...