Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/20/2012 in all areas

  1. This module installs a page on your Setup menu in the admin where you can manage comments (assuming you have a comments field installed). Download from the modules directory at: http://modules.processwire.com/modules/process-latest-comments/ Features include: Easily find the latest comments needing approval or moderation. Shows comments from all pages on 1 screen, paginated and in chronological order. Enables you to change the status of any comment, edit the text or delete. Filtering by status/type, cite, email or IP address Screenshot: I've been wanting to build this for a long time, and something like this should have been there from the beginning, as it's a bit tedious to keep track of all your comments on a large site without this. So this module may be moved into the core for version 2.3, in which case it'll be renamed to ProcessComments, so as not to conflict with those that may have this installed.
    4 points
  2. Hi ryan, hi PW Community. no worry about the 500th member when i saw that right at my registration i was the 501... But the main point is that i´m glad to be here !! Thanks Ralf ps: i´ve got my first post 8)
    3 points
  3. This thread started as a result of our 1500th post, and we are now well over our 15,000th, in a relatively short period of time. Now thinking of the huge celebration we should have when we reach our 150,000th post. Thanks to everyone here for making this such a great community! --- Edit: I removed the 500th member thing, as Pete correctly pointed out to me that the system still has some banned users in it, so we don't have a way of telling exactly who the 500th real member is. Sorry Ralph99.
    3 points
  4. In terms of efficiency, I remember Ryan mentioned that it's better to use count instead of find when you only need a total number of items. So the the aggregating line above can be improved a little: $categorycount[$category->title] = $pages->count("template=portolio, category=$category"); or use limit: $categorycount[$category->title] = $pages->find("template=portolio, category=$category, limit=2")->getTotal(); But the first is way cooler. Probably, you won't feel any difference, but it's always nice to know your code is optimized and works. Even when they have a gazillion items in their portfolio...
    2 points
  5. I needed a field that would allow me to select one or more templates, very much like the Page Select. So I created a module that does just that! I based it off of Ryan's FieldtypeModules because the functionality is quite similar. You can also define which templates are selectable by the asmselect field. Hope this helps someone that wants to do the same thing! FieldtypeTemplates.module
    1 point
  6. Lets see if we can get a quick-start tutorial going here. We'll start with something really simple and then work up from there. Tell me when something makes sense and when it doesn't and we'll adjust as we go. My thought is that we'd make a tutorial that plays on the 'hello world' phrase and lists information about planets in the solar system, starting with Earth. To keep it simple, we'll assume that the basic site profile is installed, as that's what comes with ProcessWire (so there's no need to uninstall anything). But we won't start using any of it's files tat this stage. Instead, we'll start out by creating our own files. STEP 1 – Create a template file Create a new file called: /site/templates/planet.php, and copy+paste the following HTML into that file: <html> <head> <title>Earth</title> </head> <body> <h1>Earth</h1> <h2>Type: Happy planet, Age: Millions of years</h2> <p>Earth (or the Earth) is the third planet from the Sun, and the densest and fifth-largest of the eight planets in the Solar System. It is also the largest of the Solar System's four terrestrial planets. It is sometimes referred to as the World, the Blue Planet, or by its Latin name, Terra.</p> </body> </html> The above is just a plain HTML file with nothing specific to ProcessWire. We will use this as the starting point for our template, and we'll go back and modify it later. STEP 2 – Add a template to ProcessWire Login to ProcessWire admin and go to Setup > Templates. This page shows a list of templates currently in the system. Click the Add New Template button. On the next screen that appears, you'll see it found your "planet" template file. Check the box next to the planet template and click Add Template. You may ignore any other options that appear on this screen. STEP 3 – Creating a page using your template Your planet template is now in the system and ready to use, but it's not being used by any pages. So lets create a page that uses the planet template. In the ProcessWire admin, click Pages in the top navigation. This is a site map if your page structure. We want to create a new page under the homepage, so click the new link that appears to the right of the home page. The next screen has 3 inputs: title, name and template. Enter "Earth" for the title, and the name should populate automatically. For the template, select planet. Then click Save. Now you have created a new page using the template that you added. You are now in the page edit screen and you should see your title field populated with "Earth". Click the View link that appears on this page edit screen. You should see the output of the HTML from step 1. Click the back button in your browser to return to the edit screen. STEP 4 – Creating a new field Now you know how to create a template and a page using that template. You could create more pages using the same template if you wanted to. But that wouldn't be particularly useful – this template file is just a static HTML file. Lets make it dynamic by creating some fields and adding them to it. We are going to create 3 fields to represent the pieces of data that currently appear in our static template. These include the planet's type, age in years, and a brief summary. We will call these fields: planet_type, planet_age and planet_summary. In ProcessWire admin, click Setup > Fields. This screen shows a list of fields currently in the system, most of which are general purpose fields for the basic profile. For the purposes of this tutorial, we are going to ignore those and create our own. Click the Add New Field button. On the next screen, enter "planet_type" for the Name, select "text" as the Type, and enter "Planet Type" for the Label. Then click the Save Field button. Now that your field is saved, you are on the Field Edit screen. At this point, your field is created and ready to be added to your planet template. Optional: While editing your field, click the details tab where you'll see a select box for Text Formatters. Select "HTML Entity Encoder" – this ensures that characters like "<", ">" and "&" will be converted to HTML entities and not confused as HTML tags. While not required, it's a good practice for text fields like this. After you've done that, click the Save Field button. STEP 5 – Creating more new fields In step 4 we created the planet_type field. Now we want to create the planet_age and planet_summary fields. So in this step, you'll want to do the same thing for the remaining two fields: Create the planet_age field exactly like you created the planet_type field, but enter "Planet age in years" for the label. Create the planet_summary field exactly like you created the planet_type field, but chose "textarea" as the Type and enter "Planet summary" for the label. Note that a "textarea" field is just like a "text" field, except that it can contain multiple lines of text. STEP 6 – Adding new fields to your template Now that you've created 3 new fields, you need to add them to your planet template. In ProcessWire admin, click Setup > Templates > planet. You are now editing your planet template. In the Fields select box, choose planet_type, then planet_age, then planet_summary. You will see each added to the list. Cick the Save Template button. STEP 7 – Editing a page using your template Now that you have new fields added to your template, go back and edit the Earth page you created earlier and populate the new fields that are on it. In ProcessWire admin, click Pages at the top, then click the Earth page, and click the edit button that appears to the right of it. You are now editing the Earth page you created earlier. You should see the new fields you added, waiting for text. Enter "Terrestrial planet" for Planet Type Enter "4.54 billion" for Planet Age in Years Paste in the text below for Planet Summary and then click Save. STEP 8 – Outputting dynamic data in your template file While still in the page editor from step 7, click the "View" link to see your page. Note that it still says "Happy planet" for type (rather than "Terrestrial planet") and "Millions of years" rather than "4.54 billion years". That's because the page is still being rendered with just the static data in it. We need to update the template file so that it recognizes the fields we added and outputs the values of those fields. Edit /site/templates/planet.php and replace the static text in there with tags like this, replacing field_name with the name of the field: <?php echo $page->field_name; ?> If supported by your server, you may also use this shorter format which some people find easier to look at and faster to enter: <?=$page->field_name?> Here is the /site/templates/planet.php file updated to output the content of the page using tags like the above: <html> <head> <title><?php echo $page->title; ?></title> </head> <body> <h1><?php echo $page->title; ?></h1> <h2>Type: <?php echo $page->planet_type; ?>, Age: <?php echo $page->planet_age; ?> years</h2> <p><?php echo $page->planet_summary; ?></p> </body> </html> After making these changes, save your planet.php template file. Now view your Earth page again. You should see it properly outputting all of the content you entered on the page, including "Terrestrial planet" for Type and "4.54 billion years" for age. Any changes you make from this point forward should be reflected in the output. STEP 9 – Creating more pages, reusing your template For this last step, we'll create another page (for Jupiter) using the same template just to demonstrate how a template may be reused. In ProcessWire Admin, click Pages and then click the new link to the right of the home page. Enter "Jupiter" as the Title and select "planet" for the Template. Click Save. Now that you are editing the Jupiter page, enter "Gas giant" for Type, enter "4.5 billion" for Age in Years, and copy+paste the following for Planet Summary: Click the Publish button and then View the page. You should now see your planet template being used to output the information for Jupiter rather than Earth. CONCLUSION In the above, we covered the basics of how to develop in ProcessWire, including the following: Creating templates and their associated template files Creating basic text fields and adding them to templates Creating and editing pages that use your templates Outputting the values of fields in template files If all of this makes sense so far, I thought we'd follow up next with a tutorial to take this further: Adding and outputting photos for each planet Creating navigation that lists all the other planets that have pages in the system …and we'd keep building upon the tutorial from there. If you all think this tutorial is helpful, then perhaps this can be a draft for a real tutorial we'll put on the site, so all of your help is appreciated in making this as good as it can be.
    1 point
  7. hello forum, after a bit a humble start i think i've wrapped my head around pw a little better... that's why i'm now in the general support forum and not any longer in getting started ;-) however, i'm working on a portfolio site for an engineering company and i've set up categories to organize the way their work is presented on the site. setting up the categories was easy and works good thanks to the tutorials in the forum here. but now i would like to present the categories as a tag cloud and therefore need to get the number, how often each category has been chosen for a portfolio item (aka page). this is a bit over my head in php. could someone point me in the right direction? thanks pretty much in advance!
    1 point
  8. Yeeeees! Thank you Ryan Now just hoping to get some projects I can build with ProcessWire...!
    1 point
  9. Nice one Ryan - PW just keeps on getting better!
    1 point
  10. Hi all, Here's my first site using Processwire, a site for a friend of mine who is an illustrator. There's still a fair bit of tidying up to do but this is what I have so far... Feedback more than welcome. Processwire is an incredible framework, I'd use it again and again for projects now. Thanks for all of the hard work put in to making such a great tool. Anyway, here's the site: http://amberanderson.co.uk/ Thanks!
    1 point
  11. Hi ryan, Here's the error message of the bugged module: Parse Error syntax error, unexpected T_VARIABLE (line 55 of /opt/lampp/htdocs/cultideias_site/site/modules/TemplateTwig/TemplateTwig.module) This error message was shown because you are logged in as a Superuser. Error has been logged. This error is due to a missing semicolon in the end of line 53 of the TemplateTwig.module. The theme I was using at the time of the error is the Futura theme but the problem maintains with any theme I tried after. Even if I copy the default theme from the wire folder. Here's a screenshot: http://img254.images...ermissionsp.png Thank you, Nelson Edit: Well, I found out what was causing the problem. Today I had been fiddling with the .htaccess file and changed this line RewriteCond %{REQUEST_URI} (^|/)site-default/ to RewriteCond %{REQUEST_URI} (^|/)site/ because, well I thought it was related to the site folder and it really was but I ended making a mess of it. Apache rules still look like italian to me, I can read it but can't make sense of it. Thank you for your help and sorry for the trouble.
    1 point
  12. You may also be able to setup an automatic sort by editing the repeater's template file and setting it under the 'Family' tab. Note that the repeater templates aren't visible in your templates list at first so you'll need to check the box to "show system templates" in the filter menu.
    1 point
  13. I'm not sure about the implementation side in this module, or whether this is a good idea for the module or not. But on the ProcessWire PageList side, the client would have to lack view access to the pages in order for them not to see them in the tree. That could also be handled on the fly by the module with a hook to Page::viewable. There may be other ways too I'm not yet thinking of.
    1 point
  14. Ok found... $page>repeatername->sort("id");
    1 point
  15. Awww! Developer love <3
    1 point
  16. Want to share a few things I've added for a magazine site I'm building: First of all, I think "priority" and "changefreq" are fairly important if you're going to have a sitemap at all. This post has some info on Google's guidelines: http://www.eduki.com...-are-important/ What I decided to do was quickly add two global fields to PW so I can set these values manually in each page: -sitemap_priority -changefreq And in the code: public function sitemapListPage($page) { $entry = ""; $default_priority = "0.5"; $default_changefreq = "monthly"; include $this->fuel('config')->paths->templates . "sitemap_module_defaults.inc"; if ($page->sitemap_ignore == 0 || $page->path == '/') { // $page->path part added so that it ignores hiding the homepage, else you wouldn't have ANY pages returned $modified = date ('Y-m-d', $page->modified); $entry = "\n <url>\n"; $entry .= " <loc>{$page->httpUrl}</loc>\n"; $entry .= " <lastmod>{$modified}</lastmod>\n"; if(!empty($page->sitemap_priority)) { $entry .= " <priority>{$page->sitemap_priority}</priority>\n"; } else { $entry .= " <priority>{$default_priority}</priority>\n"; } if(!empty($page->changefreq)) { $entry .= " <changefreq>{$page->changefreq}</changefreq>\n"; } else { $entry .= " <changefreq>{$default_changefreq}</changefreq>\n"; } $entry .= " </url>"; if($page->numChildren) { foreach($page->children as $child) $entry .= $this->sitemapListPage($child); } } return $entry; } The sitemap_module_defaults.inc file in the templates dir is so I can set some values on the fly without doing it manually: <?php switch($page->template->name) { case "blog_post": case "blog_topic": case "blog_topic_type": $default_priority = "0.7"; $default_changefreq = "daily"; break; } ?> That's done and works fine for me. Something I found frustrating with the sitemap module was that I couldn't add virtual pages I made. For example, if there's a page with urlSegments with some kind of page manipulation they won't show up on the sitemap, for obvious reasons. So what I did was add this method to the module: public function sitemapListVirtualPage($httpUrl, $modified = NULL, $sitemap_priority = "0.5", $changefreq = "monthly") { $entry = ""; $modified = date ('Y-m-d', $modified); $entry = "\n <url>\n"; $entry .= " <loc>{$httpUrl}</loc>\n"; if($modified) { $entry .= " <lastmod>{$modified}</lastmod>\n"; } if($sitemap_priority) { $entry .= " <priority>" . (float)$sitemap_priority . "</priority>\n"; } if($changefreq) { $entry .= " <changefreq>{$changefreq}</changefreq>\n"; } $entry .= " </url>"; return $entry; } And added this include to the init method before the output is saved to cache: public function init() { // Intercept a request for a root URL ending in sitemap.xml and output if (strpos($_SERVER['REQUEST_URI'], wire('config')->urls->root . 'sitemap.xml') !== FALSE) { // Check for the cached sitemap, else generate and cache a fresh sitemap $cache = wire('modules')->get("MarkupCache"); if(!$output = $cache->get("MarkupSitemapXML", 3600)) { $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; $output .= $this->sitemapListPage(wire('pages')->get("/")); include $this->fuel('config')->paths->templates . "sitemap_module_virtual.inc"; $output .= "\n</urlset>"; $cache->save($output); } header("Content-Type: text/xml"); echo $output; exit; } } And in my sitemap_module_virtual.inc file I did this: <?php foreach(wire('pages')->find("template=blog_topic|blog_topic_type") as $real_page) { $output .= $this->sitemapListVirtualPage("http://" . $this->fuel('config')->httpHost . $real_page->url . "archives/", wire('pages')->get("template=blog_post,sort=-created")->modified, "0.4", "daily"); } foreach(wire('pages')->find("template=blog_topic|blog_topic_type") as $real_page) { $output .= $this->sitemapListVirtualPage("http://" . $this->fuel('config')->httpHost . $real_page->url . "rss/", wire('pages')->get("template=blog_post,sort=-created")->modified, "0.4", "daily"); } ?> In this part, I have manipulated /archive/ and /rss/ sub-pages for each blog_topic and sub-topic(or blog_topic_type) using urlSegments. I wanted these to show up on the sitemap, even though they're probably not super important. Usually I wouldn't bother doing this if it was just these kinds of pages. But what if you have countless articles with manipulated urls that don't show in the sitemap? This is perfect example of why I did this for the future as well. I've been trying to understand how to do these things for a while, so I hope it helps someone out. EDIT: I have a download with all of my changes if anyone's interested in taking a look: http://clintonskakun.com/processwire-docs/posts/the-xml-sitemap-module-with-priority-and-changefreq-and-more/
    1 point
  17. Yeah, it's alright I suppose @ryan - thanks for this as it's perfect timing for a few things I'm intending to do too
    1 point
  18. What a timing, I just started trying to build a module. This community is remarkable !
    1 point
  19. I will give it a try, but if that works, it should all be working fine. Thanks for your help ryan. If anyone needs something similar, I am happy to share the files.
    1 point
  20. Thanks guys! I started using thomas' suggestion when I read it, and it works great. It's not perfect but at least most of it is properly aligned. I guess I have to let it go and stop worrying about indentation. Although sometimes, I really have to, because I teach part-time and I want the students to be able to read my examples easily. And yes, I'm introducing processwire to my students, instead of joomla and drupal which other schools usually use to teach cms. So there's hope that future web developers would be using processwire more and more! Thanks again!
    1 point
  21. Teppo is way too slow, always second FORUM PROTIP that I spied from Soma: quickly post something, then edit it few times. You'll win every time!
    1 point
  22. Well.. I think one thing why people lean on frameworks (at least I do) is that when framework is strict and well documented - it is nice to code knowing "I am doing this in a way it is intended". Things like "Because I use this DB class from this framework, it does take care of this and that security issue". So when you are not that seasoned developer, it is nice to have something to guide you. I think pretty similar use case is when company uses one framework to get coding standards from framework. Since PW is pretty open and non-strict (and should be), I guess many people are looking for "best standards". Partly this is probably because we are used to "this is how you should do thing X when using framework Y" - and PW answer usually is: "Well, since we are using PHP here, you can do that in many ways." But to answer more directly to your question Ryan: what I have used and found beneficial over the time on frameworks I have used: forms, input validation, file uploads, pagination, cache, authentication... I think pw already has pretty good balance on this and I haven't had need to use any other frameworks or helpers when using pw, so probably best answers comes from people who have used flourish and pw for example. But maybe validation class is something I would like to see in PW.
    1 point
  23. Wow, looks like we're about to go exponential on that graph there. The singularity is near!
    1 point
×
×
  • Create New...