Leaderboard
Popular Content
Showing content with the highest reputation on 03/09/2014 in all areas
-
This module creates a blank dashboard page in your site admin and sets it as default when you login instead of the page list. It came from a need in a few projects where I was creating modules for various user roles to use and I didn't want them to see the page list at all, but needed to display various stats and quick access buttons. For example, if you have a person who is creating invoices or doing other back-office stuff in various other Process modules then as an admin you wouldn't want them to access the page tree anyway, and there are other scenarios where you might want to have a dashboard instead of launching straight into the page list. It also requires (and adds) a permission - "dashboard" - so you can create new roles and assign the dashboard permission to those roles - something you might want to do fairly commonly if you have a lot of admin modules that you want to restrict access to. Editing the template is simple - there is a dashboard.php template file in the /site/modules/ProcessDashboard/ folder (decided to leave it in there to keep it safe, but I might be tempted to move it into /site/templates/ ) as well as .js and .css files ready to add your code to. You can use the API as you usually would to create your dashboard experience. For example, display data based on user roles or even specific users using code like this: if ($user->hasRole('invoices') { echo "Hi staff member $user->name. View invoices to be processed below: ... ..."; } if ($user->name == 'pete') { // Show some super-awesome stuff here } You can also do away with the dashboard.php template file and edit the module directly, putting your code and output in the execute() function (the way most Process modules are written) but I decided to include the separate template file to make it easier for more people to use. This does touch on areas a few other modules have addressed to some degree (like diogo's Custom Admin Pages) but this is designed for one purpose - instant dashboard creation. You can download the module here: http://modules.processwire.com/modules/process-dashboard/ This module also uses code from diogo's ProcessHomeAdmin module so that the default admin page can be overridden.5 points
-
Hey, over a year ago I build the website for the bar "Kapitl21" which is really close to where I live in exchange for a beer flat (<- was my idea ). I completely forgot to post it here. Hope you guys like it: http://kapitel21.de / Nico3 points
-
updated to version 0.0.7 Added a new flag that tells the send() method to make usage of the new logging methods for handling large amounts of recipients by using permanent storage across multiple script calls: useSentLog( true | false ) Tells the send()-method to make usage of the SentLog-methods! sentLogReset() It starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter. sentLogGet() is called automaticly by the send() method - returns an array containing all previously used emailaddresses sentLogAdd($emailaddress) is called automaticly by the send() method - stores each successfully sent emailaddress into the provided log This is intended to use within third party modules for newsletter systems. All three sentLog methods are made hookable, so, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here. The usage is really simple, I think. When starting a new Newsletter Session, you once have to call wireMail()->sentLogReset() to clear any previously stored content in the log. This best should be done manually / interactively I think. After that you only have to set the useSentLog flag to true, e.g by passing an options array into the procedural function call $options = array( 'sendBulk' => true, 'useSentLog' => true ); $numSent = wireMail($to, $from, $textBody, $options); or in object-oriented style like this $numSent = wireMail()->sendBulk(true)->useSentLog(true)->to($to)->from($from)->body($textBody)->send(); That's all. Now you can call your newsletter sending script multiple times (for example bind to lazy cron) and no recipient get lost nor will receive multiple messages. No more worries about script timeouts or other interruptions, just call your script in regular intervals, but ensure that only one instance is running at the time and not multiple in parallel. It would not mess up the logfile because it uses filelocking, but you may get trouble with your SMTP provider if you stress the server. PS: @Nico: want to test it in the near future?3 points
-
I have been using this for a while now and it is incredibly useful. They have also just released a beta version which is so clean I am sure there are other tools out there like it, but this one has made my life so much easier many times. http://json.parser.online.fr/beta/ Be sure to check all the options under the settings cog!2 points
-
Hello fellow Aussie, I'd probably trash the directory on the server and reinstall it: If you're running 2.4 install it through the Modules tab > New > enter InputfieldCKEditor where it says ModuleClassName If you're sub-2.4 get hold of the ModulesManager (which needs JqueryDataTables installed first) and install it that way.2 points
-
It's worth mentioning that whilst I've made it easy for newcomers to modules to create a dashboard template, it is worth learning how Process modules work so that you can create your own to do some amazing stuff in the ProcessWire admin. See the ProcessHello module as a starting point: https://github.com/ryancramerdesign/ProcessHello EDIT: There was also another way to do this module - I could have skipped creating a separate dashboard page under the admin page and simply made the admin page load the dashboard, however I quite like having the link in the menu at the top of the page so it's really obvious how to get back there.2 points
-
thanks for the great framework. Processwire is just awesome and all the people here are awesome too2 points
-
2 points
-
On an inputfield on front end form you use $f->maxFiles = n2 points
-
Welcome gyaani! Note that if the field is an array, then echoing it out will not help you much; you will need to loop through the field (e.g. fields such as images where the field accepts multiple images, multiple pages reference fields, etc...)2 points
-
If you are looking for pretty: http://www.json-generator.com/ and http://www.jsoneditoronline.org/ ...and cool: http://jsonmate.com/ ...and complicated? http://jsoneditor.net/2 points
-
Probably you are either hitting the time limit of your php script or then your server runs out of the memory. To avoid time limit issue, put this on top of your script: set_time_limit(0); That might be all you need. But probably you will hit memory issues too, since PW keeps pages in cache. At some point memory issues come - if not with 2000 pages, then probably with 20000 pages or so. That is easy to avoid, just call this at the end of your foreach loop: wire("pages")->uncacheAll(); Also make sure you don't have debug mode on when running this kind of scripts (there will be memory leak, since debug mode logs all queries in memory). I myself like to create this kind of scripts as a command line script. More information here: http://processwire.com/api/include/2 points
-
Hi, I just uploaded the first version of the SchedulePages module to Github: https://github.com/f...r/SchedulePages This plugin module allows you to schedule (un)publication of pages. I hope you guys will like it. //Jasper Usage: ====== Place the SchedulePages.module file into the site/modules folder and install the plugin from the admin area. Install/activate the LazyCron module (if you haven't already). This module is part of the Processwire core, but it isn't activated by default. Add the following date fields to your template: publish_from publish_until Note: the fields are already created during the installation of the module That't all. LazyCron will run take care of (un)publishing your pages that have a the publish dates set. It will run on every hour. Please note: LazyCron hooks are only executed during pageviews that are delivered by ProcessWire. They are not executed when using ProcessWire's API from other scripts. Edit: Changed the name of the module and function as Ryan suggested below. Edit 2: Updated instructions. Required fields are now automatically created and from now it runs every hour. Edit 3: Added module dependency. The updated module is on Github1 point
-
I didn't know this one Shortest way to echo a variable only if populated (using pw fields of course ): echo $page->field?:''; and: echo $page->field ?: "field is empty"; // echoes field content echo $page->empty_field ?: "field is empty"; // echoes "field is empty" or even: echo $page->field1 ?: $page->field2 ?: "they are all empty";1 point
-
Just spotted a PW on Nginx installation tutorial on how-to-forge. I quite like that site - find it useful from time-to-time - so big thanks to Falko Timme for taking time to write it up. Nice1 point
-
Hello guys, long time listener, first time caller (or something like that) Night Attack is the new independant version of the NSFW show podcast hosted by Brian Brushwood and Justin Robert Young. And I'm sure you'll all be happy to hear it's powered by ProccessWire. The quick feature list: Processwire 2.4.0, nginx + php 5.5.9 with cloudflare in the front Includes 3 different quality podcast feeds (all based on the data on episode pages) Uses the alternate template filename for render, wrapper has this at the top: // Get the page content ob_start(); include "{$page->template}.php"; $content = ob_get_clean(); and then content is output with <?= $content; ?>. This way the templates can even be just html Made in less than a week (might had started 4~5 days before going live, can't remember) Modules: AIOM+, Page Edit Soft Lock, Piwik Analytics and a custom module to ensure rss feeds have correct content type when cached I mainly focused on the code side while the design was done by sebgonz.1 point
-
Wow - a solution in 12 minutes! Thanks Marty - reinstalling the module using the New option on 2.4 worked like a charm and was less work than trashing the directory on the server. Nice site(s) too!1 point
-
1 point
-
Hi Ralf, If I understand correctly, it should be a simple matter of: if($page->Departure_AUI){ echo "<div>Aui: {$page->Departure_AUI}</div>"; } There are shorter/cleaner ways of doing this, but I think this is the most understandable for someone new to php. Hope that helps!1 point
-
You're right. "process" is a field on the "admin" template, to select the module that defines the process for the admin page. So it's simply saying "make the process of this page this module". And yes the execute() is used as the default method to return the content for the admin page, basicly what you see when you open an admin page, for example /processwire/myadminpage/. Further urls segments can be used by adding other executeName() methods, where Name is the urls segment appended to the admin page url. Like /processwire/myadminpage/save/ would map to a executeSave() method in the process module. If it does exists, it will use it instead of execute() /processwire/myadminpage/mymethod/ would map to a executeMyMethod(). I think it's case insensitive.1 point
-
You'll also get errors when you use $config->paths->root in images etc (500 i believe) but if you use $config->urls->root you'll get away with it. I believe there's a different way of approaching things. Not sure why, never really looked into it but if someone is able and willing to explain that would be nice!1 point
-
The http://modules.processwire.com/modules/all-in-one-minify/ does output minification. Use it myself a lot. If it suits your work-flow there's a lot more goodies you can use it for.1 point
-
I added that to the layout.css file to fix the issue - thanks. I also set the top buttons back to display: none in global.css as ryan mentioned they should be hidden on mobile.1 point
-
1 point
-
@Zahari: nice video, nice car. Maybe you find this interesting for some stills in your videos: http://www.photofilmstrip.org/1-1-Home.html I have used it here on this old (and private) site where a 6 year old child want to present his new built time machine. (the video is the sepia one)1 point
-
Hi gyanni and welcome to PW! You can echo out any field that is available in the template that is assigned to the page you are viewing, just like in your example. Drag and drop sorting of the fields in the template changes the order that the fields will appear in when editing any pages that have that template assigned to them. Does that make sense?1 point
-
Hi Adrian Thanks again. Yeah. ProcessWire is such immense fun! BTW, for anyone reading this in the future... just needed to change $pages->get to $pages->find This got me the pages that were using the video... foreach($pages->find("video_selector=$page->id") as $article){echo "<li>{$article->title}</li>";} Just as an aside Adrian, you might be interested in watching this video I did. Video is the next thing I need to practise on. Once I have gotten my website sorted, I can spend some more time working on taking videos. The concept here is mix still photos with video clips. Totally unscripted and on the fly.... Why watch it? 2 reasons. Nice car. Shot with a handphone and the first video on it at that. https://www.youtube.com/watch?v=gYM8cPQRE8k My sites really coming along well. Can't wait to add your awesome video thumbs module in soon. All hail Adrian!!!! Cheers guys Oh! I didnt realise the video will show up here. I didnt mean to spam the site. Just thought it would show up as a link1 point
-
Hey Pierre-Luc, There is actually a note about https on github: https://github.com/ryancramerdesign/TextformatterVideoEmbed/pull/3 Perhaps you should add to that issue, or start a new one. That will be the easiest way for Ryan to track the problem.1 point
-
1 point
-
Hi Adrian Very appreciative for your looking at this Before your last reply, your previous one gave me the hint I needed.... Thanks to you it dawned on me that on say video page id = 3, I could select for pages that have a video selection field whose id = 3. This would tell me which page or pages have "used" or "contain" this video. And in your latest reply you have shown me how to do it!! Thank you thank you! :) So my problem is solved. BUT.... Just for discussions sake now.... as there is no problem anymore... My understanding was that pageStack could be used to end up to do exactly what you have suggested above, i.e. I assumed that it could be used to generate the list of article page/s that were rendering a particular video page. So, I thought that pageStack was an alternative way of generating the very list that your code above would generate. I did not think of doing it the way you suggested earlier. But I'm glad you showed me it as I can see that that concept is a great one! I guess I made a wrong assumption here about pageStack. But all is not lost. pageStack has come in useful today! In my case, I've been using template classes within template files to enable me to reference external markup files to sort of lay things out in my own (amateurish) MVC layout.... Thanks to pageStack I can now get away with using one video markup file for the two cases its needed. On the article page we just get the central portion of the markup that deals with displaying the video, and on the video page, we can add our header markup and with the code you gave me, the markup where the video is being used Something like this // In Video Template // We use pageStack here to test if the video is being rendered via its template video or in an article page. if (!count($options['pageStack'])) { $page->set('requester', 't_Video'); // this will resolve on video template pages only, not article pages. } // In External Video Markup File if ($page->requester == "t_Video") { // Displayed only if we are looking at it on one of our video pages along with it's native t_Video template. All basic stuff for you guys Im sure... Big step for me thou... Anyways thanks Adrian and Soma!1 point
-
I don't think I completely follow - if you are on a page with a single blog post, then $page should refer to that one post. I am not sure why you are selecting the children of the page. However, if you are on a parent blog page showing more than one post, then you'd need to limit your selector to each specific post. If neither of those make sense for what you're trying to do, you could get really ugly and populate an array inside your foreach and only echo the author if it is not already in the array: $authors = array(); foreach ($page->children->find('author!=""') as $child) { if(!in_array($child->author->title, $authors)){ echo $child->author->title; } $authors[] = $child->author->title; } But you really shouldn't have to do that - I think you just need to get your selector specific to your post.1 point
-
@Martijn, this module is great! i just tweaked it to work with the new version of Fontawesome; i can send you the changes or make some gists?; just some small changes here and there to get it working with the fa- class as well as using the fa class by itself to get the icons to render; also since fa is included in the admin, no @import is necessary... while this module might seem redundant with the core fontawesome icon capabilities, there are some situations where this module is more flexible, like with having an icon on any page (based on iD) without specifying at the template level... also, this module is much easier for me to be able to setup a whole lot of icons at once instead of opening all the templates to make changes.. and the custom CSS file in the templates folder makes it really easy to color code or otherwise add specific styling to selected icons; i guess if people still want this module to support IE7, there should be a different version for this, which doesn't include the fonts, and just gives you the control screen for specifying the page ids, templates and font classes..1 point
-
I've been doing a bit with JSON recently and found something similar (although not as nice): http://jsonviewer.stack.hu/1 point
-
1 point
-
Ok, here it is: Modules Directory: http://modules.processwire.com/modules/process404-search/ Github: https://github.com/adrianbj/Process404Search Includes a small tweak to also convert dashes and underscores to "+" which should improve search results.1 point
-
1 point
-
Whether it's drinking beer (nothing wrong with that, by the way) or something else, just keep us posted.1 point
-
Looks like I had accidentally introduced dependency to PW 2.4.0 with one of my earlier commits. Version 1.3.4, just pushed to GitHub, fixes this.. and again, thanks for reporting this, @homma!1 point
-
Not sure what you are after but maybe this might help: http://processwire.com/talk/topic/2300-structure-best-practice-grouping-in-admin/ http://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/ But looks like you over-complicate your approach. ProcessWire uses a hierarchal structure for pages you setup in the backend. In your templates you can call whatever page you want. http://processwire.com/api/templates/ section: finding and loading other pages from your template file http://en.wikipedia.org/wiki/ProcessWire Quote: ProcessWire is built around a page content tree (as opposed to a bucket system). The URL or path of each page is always reflective of its place in the hierarchy. One uses this same path to reference the page in the API. As a result, this connection of the path to the internal tree hierarchy is important to the architecture of ProcessWire. Beyond the parent-child relationship implied by a content tree, ProcessWire supports relational one-to-one and one-to-many references between pages in the tree.1 point
-
As Jeff pointed out, your example should work as coded. However I am thinking from your example that you don't actually want the repeater id, but an auto-incrementing number starting at 1. Is that right? If so, simply define: $i=1 before the foreach starts and then $++ just before the loop closes. Then use the $i instead of $item->id Does that help?1 point
-
GoCardless is for Direct Debits, and you don't get the money as quick as other solutions (minimum 7 days I think for the first payment whilst the DD is being set up) but it is good for certain things, especially as credit/debit cards expire but DD's are based on your bank account details - and how often do people change bank? Less often than their cards expire Stripe is really good - better fees than PayPal and better interface. You can pretty much implement their Checkout example and you're up and running in no time (relatively speaking): https://stripe.com/docs/checkout1 point
-
I like being verbose! If this { do that } or else { do this } or if not { do this } ok go on then { do this instead } Much cleaner1 point
-
@pers0n: go back to the first page in this thread. Events are not the purpose of this fieldtype. Events are just used as an example. The purpose of this fieldtype is for you to modify it specific to the data you need to represent, whether a table of inventory, prices, people, or any kind of tabular data you want. Even if you actually wanted to use it for events, you'd still want to modify it for the type of events given that it's not that useful in it's demonstration state. This fieldtype is meant to be changed by you.1 point
-
Introduction Dear community. As some of you may know I've been busy creating a MVC Module for Processwire. I've finished quite a bit of it and I am now ready for a tutorial on a quick website to get you started! For this tutorial I am using a clean install of Processwire 2.3 and my Module 0.2.4 Get the module at Github http://github.com/hawiak/mvcmodule . Main focus of the module is to split logic from design without losing the flexibility of Processwire we all fell in love with. Alright lets get started. Installation Once you have the module downloaded we are going to install it, we need the MvcModule folder in the /site/modules folder. And we need the AppController in the /site/templates folder (You can find the AppController in the /site/templates folder) Once you've put the folder in there we are going to install the module, check for new modules and you'll see MvcModule Click on it and hit install to install the module. Once you've installed the module you'll see some configure settings and you'll notice a new tab on your admin. But click submit, dont forget this or all the paths WONT WORK! Setting up your home controller Ok we are ready to set up our first controller. To easily set up your template to enable MVC we are going to the MVC tab in your navbar. You'll notice a button saying " Create controller" Click on "Create controller" and for this tutorial we are going to use the home template, select the home and click "Create". If everything is correct you will see this: Now we are done in the process side of it and we'll get into the coding. Get your favourite code editor open and lets create our controller. Open the /site/templates/home.php file in your editor. Remove the code thats in there completely. And save it. For the module to work with the template file we need to create a class called HomeController and extend AppController. like so: <?php class HomeController extends AppController{ } Creating Views and layouts If you go to your websites homepage you'll see something along the lines of: Thats because by default you will need an Index method, a home method for your controller, so lets create one! <?php class HomeController extends AppController{ public function index(){ } } Lets try it again! Oops... Well it seems like we're missing a view, so lets create the view, we first need to create a folder with called Home (the same as the controller name but start with capital) And in that folder we'll create a file called index.tmpl Now of you run it you'll see that you are not quite done yet you'll see something like this: I promise after we create the layout we are done. So lets create a folder called layouts and a file called layout.php in there. Displaying data Now we're done with the setup and we can start coding, lets say you want to get the content fromt he field body on your page displayed? Well thats easy put this in your index method. $this->set('body', $this->page->body); What this does is that it sets a variable in the view we can use called body so all we need to do to display this is go to our view. And add {{body}} to the view. Now go and refresh your page! oh wait... nothing shows up...? Oh yes we use Twig template engine we need to add this to our layout.php {% block view %} {% endblock %} (Yes yes I know its complicated for just a simple task but trust me you'll love it later!) Refresh your page and check it out! You'll see that the text is displaying but the markup isn't really working, we need to use the |raw extension in order to make this work, so change the index.tmpl content to this {{ body|raw }} Use |raw for all the HTML markup, always. Styles, scripts and snippets Now this is quite boring, I know but lets start doing some interesting stuff, lets implement Bootstrap! go and download bootstrap at getbootstrap.com Once you've downloaded create a folder in /site/templates called "assets" the dist copy the bootstrap.min.css out of /dist/css to /site/templates/assets/styles and /dist/js/bootstrap.min.js to /site/templates/assets/scripts/ Now we want to use this, MvcModule has some great options for this! Change your HomeController to this <?php class HomeController extends AppController{ public $scripts = array( '1' => 'bootstrap.min.js'); public $styles = array( '1' => 'bootstrap.min.css'); public function index(){ $this->set('body', $this->page->body); } } Now go over to your layout and change the contents of your layout to this: <head> {{ this.render_headers()|raw }} </head> {% block view %} {% endblock %} You'll now see your style (If not try going to the MvcModule configure settings and remove the first / from /site/templates/assets) Now we forgot to include JQuery, so lets download jquery at jquery.com We need to put that in the /site/templates/assets/scripts And we need to put it in the array, you can just do that as follow: public $scripts = array( '2' => 'bootstrap.min.js', '1' => 'jquery.min.js'); The number in this array indecates the order on which the scripts will be loaded. Now you should see something like this! Now lets create a navbar with all the pages using the bootstrap navbar component. To do this we will create a snippet create a folder called snippets in /site/templates and a file called navbar.php Lets first create a variable with all the pages in the index method $this->set('menu', $this->pages->find('/')); Lets now create our snippet, lets just create this first in our snippet navbar.php <nav class="navbar navbar-default" role="navigation"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Link</a></li> </ul> </div> </nav> We need to tell the controller to use this snippet we do that by using an array. Change your controller to the following: <?php class HomeController extends AppController{ public $scripts = array( '2' => 'bootstrap.min.js', '1' => 'jquery.min.js'); public $styles = array( '1' => 'bootstrap.min.css'); public $snippets = array( 'navbar' => 'navbar.php'); public function index(){ $this->set('body', $this->page->body); $this->set('menu', $this->pages->find('/')); } } And change your layout to this: <head> {{ this.render_headers()|raw }} </head> {% block navbar %} {% endblock %} {% block view %} {% endblock %} You see that I created a block here and called in Navbar. The snippets content (that we assigned to navbar => file_name) will be put in this block! So lets now use our variables and the Twig template engine to the fullest! Change the navbar.php snippet to: <nav class="navbar navbar-default" role="navigation"> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> {% for item in menu %} <li class=""><a href="{{ item.url }}">{{ item.title }}</a></li> {% endfor %} </ul> </div> </nav> You see we use a for loop here and use the PageArray menu here and generate the menu here. You can use the variables in the view as well. Setting a title Lets set a title, this is fairly easy, lets define a variable in our controller that will be the same for every view in this controller public $title = "Home controller"; Now go to your layout.php and do add this to the head: <title>{%block title %}{% endblock %} {{ this.controller.title }}</title> Now as you can see we created a block, what this allows us to do is create the same block in the view like this: {% block title %}Index{% endblock %} And you will see that your title is "Index Home controller". This is because the title block replaced the title block in the layout file. Views Inside views you still have access to processwire objects and even to the MvcModule as you've seen with render_headers(). The view template used is Twig, check out more here http://twig.sensiolabs.org/doc/templates.html This is a basic setup for a website with MvcModule. I will extend this tutorial and update it whenever needed!1 point
-
PHP's date expects a Unix timestamp. $page->closing most likely returns a formatted date that is set in the fields output formate setting. Try: <?php echo date("Y-m-d", $page->getUnformatted("closing")); ?> The created and updated system values return unix timestamps by default i think, so this is why they work in your example.1 point
-
Why not just specify it in your html output: <a target="_blank" href="<?=$page->get('redirect_url|url')?>"><?=$page->title?></a> If you need an option to choose between opening your redirect page in a new tab/window and the same window you could add a new field to your redirect template, let's call it "blank" and the caption "Open in a new window?" with the type of checkbox. And then check against it in your code. So it would look something like this: $blankAttr = $page->blank ? 'target="_blank"' : ''; <a <?=$blankAttr?> href="<?=$page->get('redirect_url|url')?>"><?=$page->title?></a> Edit: also it should be possible to detect whether your url is intenal or external using some tricky regexp and avoid using additional field, but my knowledge of regexps is very limited so can't advise here. Cheers.1 point