Leaderboard
Popular Content
Showing content with the highest reputation on 04/11/2012 in all areas
-
I created a simple blank install profile for ProcessWire. I think it has been asked for a couple times, although the basic site is something really good to start with and fast to get rid of things you don't need. However in case someone wants one here it is. https://github.com/s...ireBlankInstall PROCESSWIRE 2.+ BLANK INSTALL ============================== This is a blank site profile for ProcessWire2+. It's done using the ProcessExportProfile module. There's only the following left in this profile: Fields: - title - body ProcessWire Templates - home - basic-page Template Files - admin.php (required) - home.php (required root page) - basic-page.php (404 page) INSTALLATION ============================= Get the latest ProcessWire install package. Before you install, replace the folders /basic-site/install /basic-site/templates with the ones from this blank install. Proceed with the installation as usual.3 points
-
This is my first module, and you can see how it started on this conversation http://processwire.c...0302#entry10302 It allows you to add images from an image field to any place of a text area by inserting this tag {fieldname:n}, where "fieldname" is the name of the image field, and "n" is the position of the image in this field. It will output markup on this format: <img src='$image->url' alt='$image->description'> To activate it on a text area field, go to the DETAILS tab on this field EDIT page, and choose it from the Text Formatters options. edit: on version 1.1 you can output all the images from one field at once by giving a 0(zero) index: {fieldname:0} IMPORTANT!: At the same time as I built this module, adamkiss started building a more robust module with the same functionality http://processwire.c...ld-tags-module/. We decided to merge efforts on his module so, possibly I won't work on updating this one anymore. I'll keep the download file in this thread for reference though. EDIT: created a GIT repo for this module. For downloading the module, head to: https://github.com/ocorreiododiogo/PW-ImageTags1 point
-
Here is a site I made for the Learning Center I do IT for. My goal was an interactive and responsive feel. Still to add some more media like pics and such, but it's the V1.0. The client is able to add new 'curriculums' and such through the admin gui by only typing a short description, and adding an icon image. http://www.i-workshop.com.cn/1 point
-
Who, I wonder, among the PW forum dwellers, is using Readability? If you are, did you read the terms and conditions before you signed up? As I've seen readability mentioned somewhere on the forum I thought I'd download it and try it out. I don't always take time to read scroll to the bottom of some new package's terms and conditions, but I thought I would for this one as it isn't on Mozilla's add-on site and my spider senses were tingling. I am so glad that I took the time to do so. For lurking there, in the not-so-small print*1, was the following phrase... Let's just look at that again, with a little more focus... As my real name is John Connor*2, I didn't agree and promptly deleted the add-on. For those of you who are using readability, or thinking of doing so; don't say I didn't warn you. *1Really. *2 Not really.1 point
-
Thanks for the comments! I uploaded a new version based on those suggestions. Corrected. I'm glad PHP doesn't punish bad English yet I want to add this feature on a future version, but I don't want to implement it directly on the tags because it should be the designer, not the editor, to have control over it. Maybe adding it to preferences of the module would be the way to go. I don't think it would be possible to make it on a per field basis... Done, thanks! I implemented this but, at least for now, instead of {images} it will use index zero {images:0} to output them all. There are several reasons for this: It was faster to implement; it uses only one preg_match instead of two; and it prevents accidental use of tags by the editor — it's more unlikely that someone will type {images:0} on a text than {images}. Done!1 point
-
adding title field solved, thanks... how I made templates without them, I do not know... pb1 point
-
Haha, I knew I had to be fast, this was such a great question. I don't want anyone to believe building modules for PW is hard, it's not.1 point
-
I suggest not extending the User class, and instead plugin to it with a module class UserExtended extends WireData implements Module { public static function getModuleInfo() { /* return your array here */ } public function init() { $this->addHook('User::sendThankYou', $this, 'sendThankYou'); public function sendThankYou($event) { /* do something */ } } The above would add a sendThankYou method to all User instances. Your sendThankYou method can gain access to the $user the method was called on like this: $user = $event->object; Your sendThankYou method can also have one or more arguments if you want it to: $arg = $event->arguments[0]; If you want your sendThankYou method to return a value, do it like this: $event->return = 'value you want to return'; Looks like Antti beat me to it.1 point
-
/site/modules/UserExtension.module <?php class UserExtension extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'User Extension', 'version' => 101, 'summary' => 'Extends $user object.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHook('User::sendThankYou', $this, 'sendThankYou'); } public function sendThankYou($event) { $user = $event->data['object']; $event->return = "Thank you, $user->name"; } } Usage is dead simple: <?php echo $user->sendThankYou() ?>1 point
-
This is a fairly complex pagination scenario. I can see why you want to get it all in 1 find() operation here, and if the option I mentioned works, I would probably use it. But if not, you'll need to adjust your setup to perform pagination and sorting at the $pages->find() level, rather than after. Your $posts->find() is not setting pagination details to the PageArray it returns to you because all those pages are already in memory, and pagination is assumed to be for stuff that is not in memory. Writing in the browser here, but try changing your example to this: $template = $templates->find("name^=post_"); $parent = $pages->get("/beitraege/"); $posts = $parent->children("template=$template, post_confirmed=1, sort=-created, limit=10"); if(!$user->isGuest()) { $posts->import($parent->find("template=$template, user=$user, sort=-created, limit=10")); $posts->sort("-created"); // sorts with the previous results } A caveat is that the items-per-page is going to be somewhere between 10 and 20 rather than always 20, at least if the result set is not large. The other caveat is that it's not going to show more than 10 of the given type in each pagination. These may or may not be issues in your case, but just wanted to mention it. There are ways around it, but it'll take more code. Note the way I'm using the $template var requires the latest PW (or at least one from the last month). You no longer have to do something like implode('|, ...) in recent versions.1 point
-
@Ryan: Well, I never did it before, but I guess it shouldn't be that hard to setup a wiki. So I would try it1 point
-
Why not just delete the fields you don't require? Makes things simpler.1 point
-
Hello, looks like I've come across an amazing tool here. I am quite new to processwire and don't really have an skills in php. What is intriguing to me is the simplicity of the UI for the client and having more control over the 'building blocks'. This post has been quite helpful in understanding the way pw is built (header and footer). Any tutorials for designers with little knowledge of coding is highly welcome, I would of course love a walkthrough for customizing the demo website (hope I'm not alone). Thanks for sharing!1 point
-
I ran and decided to just host it on my own~ got them to point the A Records to my cloud server and spent the evening figuring out how to make virtualhosts1 point
-
When it comes to objects (like pages), I think that using === is more efficient than == because: // compares that the two objects are the exact same instance, holding the same spot in memory // this is just 1 quick comparison $page1 === $page2; // compares that the two objects have all the same properties // this spawns potentially lots of comparisons (?) $page1 == $page2; Rather than comparing page objects, I usually just avoid thinking about the above, and just check that they have the same ID: $page1->id == $page2->id; If you find it simpler to look at, putting them in the context of a string does the same thing as comparing the ID: "$page1" == "$page2"1 point
-
Hey Nico, after the multi-language features ryan implemented for backend and static template content, I'm still re-thinking the purpose of my module. The goal is to keep the idea of separate page trees. But basically the new module won‘t be about languages but about contexts the content belongs to. Such a context can - but doesn't have to - be a language. Or a mobile version of your site. You'll be able to define rules like url matching or client language detection to define what page tree to use. An API object var will give you the possibility to switch contexts. And it will be working together with PWs native language management. The page mapping feature will be provided by an additional module extending the context module by the mapping capabilities you know from language module. As there is still a lot work to do, I can't tell you yet when I'll be able to push a first stable version. Would need some holidays to focus on this one.1 point
-
I think you are on the right path here. The page that Jasper and Marc linked to is good when working with larger scale stuff (and smaller too), but I'm not usually that disciplined on smaller stuff. One alternative would be to bundle your news_posts.inc into a function, and keep a file with that function and any others you might need. I usually call mine tools.inc. The function would look like this: /site/templates/tools.inc function listNews($news) { $out = ''; foreach($news as $item) $out .= "<p>{$item->title}</p>"; return $out; } Your template files that need to list news (or use your other functions) would include('./tools.inc'); at the top, and then they would call the function when/if they needed to list news: echo listNews($pages->get('/news/')->children('limit=5'));1 point