Leaderboard
Popular Content
Showing content with the highest reputation on 05/14/2013 in all areas
-
If you are planning to build a template for pages that will be viewed on is own, as well as rendered from other templates try this: if ($page->url == $_SERVER["REQUEST_URI"]) include("./head.inc"); // template code if ($page->url == $_SERVER["REQUEST_URI"]) include("./foot.inc"); The head and the foot will be included only if the page is on it's own url.3 points
-
It's correct that passwords can't be retained if you are developing a site in > 5.3.7 and migrating to a server running < 5.3.8. Best bet is to avoid any web server running an old version of PHP. But if you can't do that, then you'll want to reset your password at the live server after migrating the site to it. I usually paste this into my site/templates/admin.php, open the /processwire/ URL (to run it), and then remove it. $u = $users->get('ryan'); $u->of(false); $u->pass = 'mypass'; $u->save();3 points
-
Hi there! The following code grabs first three images from the field "images" $firstThree = $page->images->slice(0, 3); foreach ($firstThree as $i) { // Output goes here }3 points
-
I've now got ProcessWire (local dev) fully converted to PDO and running with both PDO ($database) and mysqli ($db) available to the API. When in the admin, the debug mode info at the bottom highlights queries from each, so that you can more easily identify mysqli queries that you may want to convert to PDO. As a matter of efficiency, ProcessWire doesn't actually initiate the mysqli connection until you access something from the $db API variable. Meaning, the core and a stock install of PW doesn't use mysqli at all (or attempt a DB connection through it), but it makes it available if any modules or your site want it. In order to achieve this, I had to abstract the existing mysqli Database class behind a passthrough gatekeeper class. The only way you will notice that is if you are using any kind of type hinting for the old Database/mysqli class, OR if you are using procedural mysqli functions. I don't think I've seen any modules type hinting the old Database class or mysqli except for my own (like Form Builder). But I do think I've seen procedural use of mysqli at least once (I think it might have been in one of Teppo's modules?). Anyway, not sure if this matters to anyone, but just in case, here's the things to watch for with mysqli: // If you are type hinting mysql or Database like this… function example1(Database $db) { ... } // this function example2(mysqli $db) { ... } // or this // …then remove the type hinting: function example1($db) { ... } function example2($db) { ... } // if you are using mysqli procedurally with a $db param: $result = mysqli_query($db, "SELECT COUNT(*) FROM pages"); list($count) = mysqli_fetch_row($result); // use it without specifying $db param… $result = mysqli_query("SELECT COUNT(*) FROM pages"); list($count) = mysqli_fetch_row($result); // …or better yet, use the OO version: $result = $db->query("SELECT COUNT(*) FROM pages"); list($count) = $result->fetch_row(); Since PW 2.4 will be backwards compatible in terms of the database, lets not worry about switching our 3rd party modules over to PDO until 2.4 is actually out in a stable version, which is still months away.2 points
-
To avoid any duplication kongondo is talking: In latest versions (not sure if in stable yet), you can do this: $allArticles = $pages->find("template=article|image|video|audio|quote, sort-=created, limit=20"); foreach($allArticles as $article) { $templateFile = $article->template . "-teaser.php"; echo $article->render($templateFile); // It renders the content with article-teaser.php, image-teaser.php etc... } There is of course multiple ways of doing that (I rarely output any markup in templates directly), but I think that would be nice way of doing simple tubmlr-style blog.2 points
-
Thanks @arjen & @adrian for the report. And thanks @soma for giving the right solution . It definitely was a bug in this very module. I've updated the module to check id has been given as a GET parameter before using it to get the page being edited. This seems to solve the problem you guys were facing, just like soma said. New version is in GitHub and version number has been updated in the modules directory as well. @arjen: Soma was right also regarding that bitwise-and (naturally ). That line, and two similar ones elsewhere, checks if the template has the system flag set. Property 'flags' of a template is a bit field where there's possibly more than one flag (bit) set at a time. So it wouldn't be correct for example just to see if the flags value equals to the value of system flag, but it has to be done using a bitwise operator. Sidenote: actually in this very case there's only the system override flag that could co-exist with the system flag, but still that's the correct way of checking if a flag has been set .2 points
-
Just wanted to share what I recently used to create forms in modules and in frontend using the API and Inputfield modules PW provides and uses on its own. I think many newcomers or also advanced user aren't aware what is already possible in templates with some simple and flexible code. Learning this can greatly help in any aspect when you develop with PW. It's not as easy and powerful as FormBuilder but a great example of what can be archieved within PW. Really? Tell me more The output markup generated with something like echo $form->render(); will be a like the one you get with FormBuilder or admin forms in backend. It's what PW is made of. Now since 2.2.5~ somewhere, the "required" option is possible for all fields (previous not) and that makes it easier a lot for validation and also it renders inline errors already nicely (due to Ryan FormBuilder yah!). For example the Password inputfield already provides two field to confirm the password and will validate it. De- and encryption method also exists. Or you can also use columns width setting for a field, which was added not so long ago. Some fields like Asm MultiSelect would require to also include their css and js to work but haven't tried. Also file uploads isn't there, but maybe at some point there will be more options. It would be still possible to code your own uploader when the form is submitted. Validation? If you understand a little more how PW works with forms and inputfields you can simply add you own validation, do hooks and lots of magic with very easy code to read and maintain. You can also use the processInput($input->post) method of a form that PW uses itself to validate a form. So getting to see if there was any errors is simply checking for $form->getErrors();. Also the $form->processInput($input->post) will prevent CSRF attacks and the form will append a hidden field automaticly. It's also worth noting that processInput() will work also with an array (key=>value) of data it doesn't have to be the one from $input->post. Styling? It works well if you take your own CSS or just pick the inputfields.css from the templates-admin folder as a start. Also the CSS file from the wire/modules/InputfieldRadios module can be helpful to add. And that's it. It's not very hard to get it display nicely. Here an code example of a simple form. <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form->append($field); // append the field to the form // create email field $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $form->append($field); // append the field // you get the idea $field = $modules->get("InputfieldPassword"); $field->label = "Passwort"; $field->attr("id+name","pass"); $field->required = 1; $form->append($field); // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Subscribe"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); // here is a good point for extra/custom validation and manipulate fields $email = $form->get("email"); if($email && (strpos($email->value,'@hotmail') !== FALSE)){ // attach an error to the field // and it will get displayed along the field $email->error("Sorry we don't accept hotmail addresses for now."); } if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { // do with the form what you like, create and save it as page // or send emails. to get the values you can use // $email = $form->get("email")->value; // $name = $form->get("name")->value; // $pass = $form->get("pass")->value; // // to sanitize input // $name = $sanitizer->text($input->post->name); // $email = $sanitizer->email($form->get("email")->value); $out .= "<p>Thanks! Your submission was successful."; } } else { // render out form without processing $out .= $form->render(); } include("./head.inc"); echo $out; include("./foot.inc"); Here the code snippet as gist github: https://gist.github.com/4027908 Maybe there's something I'm not aware of yet, so if there something to still care about just let me know. Maybe some example of hooks could be appended here too. Thanks Edit March 2017: This code still works in PW2.8 and PW3.1 point
-
I've talked about this at various points over the past year or so and have a lot of code related to the forums software used here - Invision Power Board. What I would like to know from people is what level of interest there is in such a module. It's ideal for community-driven sites and blurs the line between site and forums. I'll admit I've gone slightly overboard with my own personal needs on one site and have a list of the following working, but not in a packaged state as of yet until I know if there is interest: Login integration (logins validated against forums, PW account created if one doesn't exist) Member bar (the one at the top of the screen here, but on your PW site) Create new posts Fetch posts from forums Reply to topics - this and the above two points allow you handle comments via forum topics instead of the Comments module - if you have privileges you can also edit and delete comments Access to all member info from the forums Latest topics list (per user-group so members don't see staff topics) Users online list Forum statistics (could be used alongside page statistics to show how many articles are on your site along with members, topics etc - you know, pointless stats that look pretty ) ...and some others I've probably forgotten I'm also interested in hearing if you would like the module to be written for other forum software as well as whether you would be happy paying for a small fee. Answers to these two questions will dictate whether I package it so it's easy to configure for other forum software as well and also whether I could afford to branch it out to other software It will have templates for some basic things too like the member bar so I just need to think of the best way to package those as well - probably have them in the module folder and moved to the templates folder during installation would be neatest.1 point
-
Why couldn't I use this in a template: if ($user->name == 'admin') { $config->debug = true; } or if ($user->isSuperuser()) { $config->debug = true; }1 point
-
InlineEditor 0.0.3 A simple, inline editor that allows you to edit text based content directly in pages themselves. Only use this to experiment. Please do NOT use this on live sites. 0.0.3 Updates Refactored process module Editor now shows result sent by server rather than a generic message New in 0.0.2 Editing repeaters work (actually always did from the beginning) All editor bar colours are now configurable through the admin panel All editable areas are now given a dashed border Few other fixes! Module page: http://modules.processwire.com/modules/inline-editor/ GitHub page: https://github.com/Sinmok/InlineEditor-for-ProcessWire Credits: Big thank you to apeisa for Fredi - whos Module inspired me to make this. It also provided a solid foundation on how to make my own module Ryan - For the whole CMS and the HelloWorld module which taught me how to hook on to page::render! Screenshots:1 point
-
First of all I apoligise for writing such a long post… was not intended. I'm happy to have found this CMS. I guess like most of us, I came here because somewhere somehow we found a reference to somewhere which leaded us somewhere else and then somehow we landed here In my case I landed here from the CMS Symphony forum, as someone there mentioned Processwire is something to watch out as it looks really cool. Anyhow I don't know if I'm an average Processwire user, and most probably no the right user to create something using Processwire. Why, well, I'm not a programmer, I really have no idea, I could not build the most simple script, I know the most basic HTML and most simple CSS and even though I was able to build simple Expression Engine websites, I'm one of those that knows somehow how to make changes in a template using Firefox firebug or build websites using Wordpress and plugins, so I'm able to build anything as far as I don't have to create much code. I don't know if there are more users as me here, anyway, I wanted to make clear which are my current knowledge limitations but I like learning. So, why am I here? because I have a personal project, I want to do it myself and although I could do it entirely in Wordpress using a bunch of plugins, I'm not sure if that would be the right choice. I have tried to make it entirely using Invisionpower Suite, and although it works in some way, it is not what I really want. So what I want to build is this: A website where users and organizers are able to enter, publish or list events or activities and those users who want to assist to those activities should be able to share their car or accommodation or meet o get know each other even before going to that activity. People who have participated in those events or activities should be able to rate or leave comments about how was that event so that next assistants know if its worth or not to go and organizers can get the benefit of feedback. Kind of an Activities and Events Community with Trip, Accommodation and Informations sharing between assistants. So that is what I'd like to offer: - The activities could be free or pay activities. - Event Organizers should be able to decide to sell pay events on this website using their own paypal or the gateway should be able to calculate a commission in case website's own paypal must be used (small commission for me, the rest for them). - Organizers and users should be able to see how much and how many events tickets are being sold and who is assisting. - People that want to assist to an event should be able to announce that they will assist and if they want, share their car or travel ways with other users going to that event. Ideally when an event is published, you could see e.g: If the event is Barcelona someone from Madrid is going to that event as well by car, so you could just contact that person from Madrid and book a seat in his car. That person from Madrid should be able to list his trip, car model, free seats, seat price, and so on, and when someone else book that seat, then it should show that already one person is driving there in that car with him so that there is still let's say two seats left… same thing for shared accommodation... so you get the idea. - Assistants should be able to share accommodation in case they live near where the event is taking place or maybe anything else… not sure what this project will lead up to, maybe users want to share anything else, or have other demands. - I'd like also to be able to show those activities in a calendar, but an Agenda view would be enough, as there is not such a thing anywhere. - Users should be able to sort and filter those activities (as I see in Processwire that is not a problem) - I was also thinking on integrating a forum but the thing is that without a proper bridge or integration, users end up having two profiles. Having a kind of SSO would be nice. So I think of several ways to do this: 1.- The Wordpress Way integrating following components: - Wordpress - wp-types.com plugins (Forms, Custom Types, Woocommerce plugin, Views) or the ACF (Advance Custom Fields) from http://www.advancedcustomfields.com/ - Woocommerce e-commerce plugin - Woocommerce extensions - Wordpress Affiliates Woocommerce Plugin - Invisionpower IP.Board - Wordpress IP.Board Bridge. - Or integrate it with the new moot comments | forum platform from moot.it, although I must say I like IP.Board. 2.- Expression Engine and the necessary modules (which I have to figure out yet), their forum module is terrible to put it kindly. And after reading their last moves about how are they dealing their Customer Support to small customers, I don't know what to think. I also don't like that in Expression Engine you are not able to add a user to more than one group and that could be a limitation when you build a community oriented website. On the other side there are tons of modules for it. 3.- InvisionPower IPS: I have be able to do most of this customizing the IP.Downloads App module but the end result has lot to be desired. And Invisionpower Suite although it is a really good product, their documentation and Customer Service is not really oriented to help users to build this kind of projects using their platform. 4.- Craft CMS which is still in development, looks really good but lacks an e-commerce module 5.- Processwire which looks amazing. I saw there is an ecommerce module but not sure if I had the necessary skills to adapt it to my needs. And on the other side I guess I'll find myself asking silly questions (for advanced users here) all the time. What do I prefer?… of course the very best thing would be to be able to make it using one single flexible platform and use as little 3rd party modules as possible. Wordpress is not a fast and secure platform and the more plugins you combine within well the slower it can get. What do I like from Processwire? - Simple - Fast - The Form Module looks amazing - The Pro Cache module looks impressive - Updating looks very easy (as I understand just overwrite the Processwire folder with the new version, change index.php and httaccess file) - Documentation (Although I'd have to read it 100 times) looks promising - Great Community, not big right now, but looks very dedicated and friendly. - I like that it works with anything on it (similar to EE) - I have seen that some built sites do similar things as what I want to build. - Built already for Multi-language in mind - It amazes me that there are so much done in such a young system. - It looks as Ryan is a kind of Genius So do you think honestly that someone with my limited skills could build a project like this using Processwire? I think I need so skills I have not right now and I'm specially worried with the commerce aspect of my project… but I'd like to know your opinions about this. Thanks Mario1 point
-
Yuhuu! Now It works! I think some variables where overwritten somewhere. Now i will prepare a new version of the module with this Class. Thank you adrian for help! PS: I have updated the credits Pdf2txt.php1 point
-
Thanks for the report guys! Redirect url on page save has changed a couple of months ago a bit and my regex was too picky. This is fixed now. I also fixed the action when field is being edited in some other context than default one. Module version is now 0.0.7 both in GitHub and modules directory.1 point
-
1 point
-
You can enable this option by editing your /site/config.php and setting $config->advanced=true; Next edit the template (Setup > Templates > edit) that you want to be able to change the createdUser. Click on the "system" tab (this is only visible in advanced mode). You'll see checkboxes for various options–check the appropriate one and save. Go back to your /site/config.php and remove the $config->advanced line you added earlier… as you don't usually want advanced mode on (some settings can be dangerous). But you should now have the ability to change the created user for pages using that template.1 point
-
That is how I would say it. Title is kind of "special" custom field, since it enabled by default for all templates. I have never removed it, even if it has been unnecessary few times. I love the fact that I always have $page->title which would give me something readable in every case.1 point
-
In this case yes, but it's just an example that can be adapted to other ways of building templates.1 point
-
Did you try using "limit=2" in your selector? The following should work. <?php if($page->numChildren) { echo "<ul class='nav'>"; foreach($page->children("limit=2")as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>"; }1 point
-
The hook you'd want to use would probably be Page::viewable. However, hiding pages that a user can't edit just doesn't work in a tree hierarchy, because how then would a user get to the pages that they can edit? A better strategy would be to figure out exactly what you don't want the user to see in the admin tree, whether it is branch of a tree, a specific page, or all pages using a specific template. And take into account the fact that nothing under the page(s) will be editable since the user won't be able to navigate to them. public function init() { $this->addHookAfter('Page::viewable', $this, 'hookPageViewable'); } public function hookPageViewable(HookEvent $event) { if(!$event->return) return; // page already not viewable $page = $event->arguments(0); if($page->template == 'my-private-template') $event->return = false; }1 point
-
Yeah its an input(field). Sorry to confuz you. ;-) Theres even an FieldtypePageName and InputfieldPageName. (A db field isnt also a field?)1 point
-
I think when hooking into page the event->object always is the page. $event->arguments is an array, and I would think that it holds the params like the original function you hook into. If you hook into function ___funcname($param0, $param1,$param2), I think you can get in your function $param0 = $event->arguments[0], $param1 = $event->arguments[1], ... EDIT: see: HookEvent #18 and following lines and see the new API-DOCs for Hooks #read_arguments! (and all above and below)1 point
-
I always sanitize all user input by default. It isn't much work and I know I'm really lazy so I have to discipline myself. It makes me sleep well at night1 point
-
1 point
-
@3finger, @onjegolders, Thanks both of you, I'll try reading the topics & using the given codes. Will keep you posted, I'm pretty sure I'm gonna have lots of questions. Thanks again, kind people like you guys make this community so great.1 point
-
$allArticles = $pages->find("template=article|image|video|audio|quote, sort-=created, limit=20"); foreach($allArticles as $article) { echo $article->render(); }1 point
-
Ok, now I know what you mean ! first: it wasn't intended to use the filename as output in the frontend, (I never had thought that one want to do that). I provide stream-Urls for playing/downloading with the frontend-handler: echo $fe->streamurl(); // outputs something like: /stream/12345/song.mp3 whereas 'song.mp3' is an optional fake filename what is needed by Yahoo-Webplayer for example. Or you simply use "/stream/{$song->id}/". Has you used the FrontEndHandler with your code? - or have you done every thing without it? (I know there were no docs with it, but I've said that it is in a very, very early state, sorry ) second: I'm not shure about data-src, (but as you use $config->urls, I assume you want use an url with it), - would one not to have to url_encode the filename? - But anyway, I never would use filenames with it, but stream-urls. ------------ @kongondo: Oho, - this is an awesome Frontend! Very cool, - feature rich, - good design. And yes, when all is ready, there should be something like a tutorial or maybe a good screencast (like Joss described how to do it). But I'm at the very beginning with the project . There are lot's to do. Just the importer seems to be stable right now. And what is really needed is some documentation that ships with the SiteProfile. I write some points down here and include them into the site later: ------------------------------------------- LocalAudioFiles provide a FrontEndHandler ($fe) for different data, - allready prepared for most usage: streamurl, (provides partial-downloads! and directly starts playing) playlist generation as m3u or pls, objects like $page, (but they are not real PW-pages) for the current page, because as of the DB-structure an album hasn't children that are songs, but it is really usefull to have children (and also it is logical). So when calling the FrontEndHandler it creates automaticaly the object for the current page: $genre, $artist, $album, $song. The $genre has PageArray artists as children, the $artist has PageArray albums as children and $album has PageArray songs as children. $album and $song have cover as PageImage, so you can use it like $album->cover->width(200)->url the FrontEndHandler also provides fully customizable FormSelectFields. You can call them like $fe->getFormSelect('album') or $fe->getFormSelect('artists'), whereas if you use genre, artist, album - you get a SingleSelectField, if you use the plural, genres, artists, albums you get a MultiSelectField! the data for select fields, - or for any other complete list is retrieved from an own Cache, that makes it really fast, once the cache is created. (after importing files, there is an option to (re)build it, otherwise it creates itself on demand) Forms for playlists, also random ones, will be send as POST-Request to /playlist/m3u/ for retrieving a m3u-playlist and to /playlist/pls/ for pls-type.With fieldnames album|albums - genre|genres - artist|artists you have to send IDs. you also can send a single song or album id to /playlist/m3u/{$id}/ as a GET-Request, (or: /playlist/pls/{$id}/) and there are more things, ... I have to write down it all, but it will take some time. I have started to add a demo section to the site, - but there are some points that needs to be coded (CacheRebuild), there are others that needs to be rewritten (CharEncoding with different ID3-Versions). The Docs need to be written, (oh, yes - I've allready said that ), ... ... and when working/playing with it, I get new ideas for new things like a playing history (has to go into stream-code, where we have control how many of a song is played, maybe when 80% of a song is streamed it counts up 1), OR - oh, now that I have $song, $album, $artist, $genre I should rewrite the getDBinfo-Methods to have not arrays but objects too: $genres, $artists, $albums, within all page-types, or, or, or, ... (- help, - I'm pinched for time ). So, - I have to find a cut and provide a useful and good understandable siteprofile, but what has some allready known limitations, and (for shure) some unknown bugs . This will be the point when ID3-CharEncoding and CacheRebuild is done, besides some minor bugs I have allready figured out and on my list. All other stuff, I think I should start later. ------------------------------------------- Here are a screencast showing what the FrontEndHandler provides, including some examples of the DemoSection: https://youtu.be/LaIZ0mpfNew1 point
-
It's "not possible". http://processwire.com/talk/topic/651-set-created-by-creating-a-page-via-api/ Some technique would be to import to a date field you add to templates and use that, or copy that date later via SQL to the pages table 'created' field.1 point
-
I think he is trying to create two pages, one manually, the other dynamically after the first one. How I understand it is that: Creating a new page memberX under the folder called member should trigger the creation of a page userX under the folder user. Edit: Maybe I am the one confused Since users, roles, etc in PW are also pages, the term "user" page can mean a new user? nway, will let onjegolders explain1 point
-
$users->add("name") Add new User with the given name and return it. http://processwire.com/api/cheatsheet/?filter=users But maybe i've misunderstood the problem.1 point
-
Thanks for the suggestion Dave, I may try this if I have time OK: The result is as follows (my hosting is stuck at PHP 5.3.5): ## Test 1 1. with MAMP PHP ver 5.4.10 install PW 2.3 locally 1. copy files and db export to hosting 1. go to login at hosting results in `Unable to generate password hash` ## Test 2 1. with MAMP PHP ver 5.3.20 install PW 2.3 locally 1. copy files and db export to hosting 1. go to login at hosting results in `Unable to generate password hash` see update 2013-05-13-1310 Conclusion: If I am correct then (since PW 2.3?—I've never seen this before so I am wondering if this came with v 2.3 of PW) if your hosting env is below 5.3.7 and you export/import a db from a local copy of a site to the hosting env then logging in won't work and will require the password being reset with a combination of Ryan's tactic and the edited Password.php file noted by Radek. NOTE: This conclusion may well be incorrect but I've run out of 'clever' and need some confirmations from those much cleverer than I on PHP/security/PW. Bottom line it's making me think I ought to upgrade my hosting past PHP 5.3.7; only trouble is it seems it's NOT easy to do this with an (mt) dv setup unless you are more of a sysadmin than I am :/ Crap. UPDATE 2013-05-13-1310: if my local env is set to PHP 5.3.20 (so like my hosting which is at 5.3.5 they are both below 5.3.7) then as long as I reset the local password as explained in 'Conclusion' above then I can now export a local db and import it over at hosting and login OK.1 point
-
Forgive me if I misunderstand the problem, but are you aware of the $config->userAuthSalt setting in config.php? /** * Installer: User Authentication Salt * * Must be retained if you migrate your site from one server to another * */ $config->userAuthSalt = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; (Around lines 223-229 of config.php (near the bottom, anyway))1 point
-
You could try using the ImageSizer class of PW. $im = new ImageSizer($config->paths->root . "myimages/IMG_09.jpg"); $im->resize(100,0);1 point
-
Here a little helper module that does it optimized using direct SQL. https://gist.github.com/somatonic/5568201 If you install module you can do: $helper = $modules->get("RandomImages"); // load module somewhere before // getRandomImages(count, field, parent) $image = $helper->getRandomImages(1,"images", 1001); echo "<img src='{$image->size(150,0)->url}'>"; Or to get more than 1 $helper = $modules->get("RandomImages"); // load module somewhere before // getRandomImages(count, field, parent) $images = $helper->getRandomImages(2,"images", 1001); foreach ($images as $key => $image) { echo "<img src='{$image->size(150,0)->url}'>"; }1 point
-
This is as simple as: $field = $modules->get("InputfieldSelect"); $field->attr("name", "myselect"); $field->addOption("myoption1", "My Option 1"); $field->addOption("myoption2", "My Option 2");1 point
-
Been having fun with this! Here's the output..A frontend demo of Horst's Local Audio Module...It's been fun playing with PW selectors and variables. First, I'd like to thank all the forum folks who've helped answer my API questions - Teppo, Soma, Diogo, Nik, etc....you know, the usual suspects.... Thanks to AnotherAndrew for this post. It led me to the nice jQuery plugin, Filtrify. Horst, big thanks for the module.! It's been a massive learning process for me besides having fun (and at times frustration ! ) along the way. There were times I went round in circles only to realise I was making simple things difficult; this is PW, the solutions are usually simple! Most of the theme is based on Filtrify's demo so all credits to Luis Almeida. Of course I won't be releasing his theme; this is just a demo (unless of course there are no restrictions). I think what I enjoyed most was the logic behind PW and how I could apply that to the demo [being a newbie and all!]. More than getting a solution I like the reasoning that comes before a solution, the journey to an end if you like. The power and sheer genius of PageReference fields and chaining selectors really clicked for me while working on this. Tools used: PW (duh!) This module (duh!x2) jTable (as I wait to learn DataTable) - for tabular track list Filtrify to create album catalogue Audio.js to play the embedded audio When this is done, @Horst, we probably want to do a tutorial/write-up about your project and how I did the frontend? Cheers1 point
-
I think grunt is close to the most interesting thing happening around the organization of frontend projects. While it is certainly great that it can do the dirty and boring work for you, it also really looks like us web developers finally have an open, stable and really flexible way of sharing our process. I have the feeling that with all the projects on Github that use it now, grunt had really come to stay, so it's definitely worth a look for everyone working with the web stack.1 point
-
1 point
-
I started with $pdo as an API variable name. But it didn't feel at home in ProcessWire, which uses clear names for all API variables (page, pages, users, input, sanitizer, etc.). The problem is $pdo feels like a brand name and someone not familiar with what PDO won't realize that it's referring to a database. So I thought it was best to call the API variable exactly what it is, which is a $database. Ultimately $database is more consistent with our API variable naming system than even $db, as none of the other API variables are abbreviated. As for confusion between $db and $database, I would only have that concern if we were planning to keep both mysqli and PDO long term. The $db will be deprecated and eventually dropped as an API variable. But we'll give it a major version or two.1 point
-
What you're doing there sounds interesting. Are you going to have Processwire itself online then or will you copy the created JSON files to be delivered by your node server? In the first case, you might try whether it isn't already sufficient to employ site caching to archive your desired performance. In the latter case you might install Processwire locally, make proper JSON templates for your data as if you wanted to just normally display them and build an index with links to all of your JSON files. Afterwards you can use a website scraper (Wget with the recursive option would be sufficient) to generate all your content, save it and copy it to your node server afterwards. You might even use some toolset (Cronjobs or the likes) that automatically transports your files to the server. The other possibility would be to write a Processwire module ("Static website exporter") that iterates the trees, renders each page with it's proper template and saves it to some folder on disk. You will probably have to deal with saving the export state and using some extent of asynchronous building to not run in a PHP timeout. You might even go crazy and build a small PHP CLI application, that includes Pw and does everything with a shell command. If you're really planning not to regenerate the files very often, I would definitely go with the second method because what you will have to do is a one-liner on your console.1 point
-
...but here it actually is an array, thus the name . When PHP sees we're dealing with strings the string representation of a variable is used. In this case the trigger is an unescaped dollar sign between double quotation marks, but it could be the concatenation operator '.' as well. To get such a representation, the __toString() method of the class (PageArray in this case) is automagically called. See http://www.php.net/manual/en/language.oop5.magic.php#object.tostring. The __toString() method has been implemented to return a single page id (Page or PageArray with one item) or a list of page id's with a '|' (pipe) as a separator. I was trying to clarify the situation but I'm not sure if that's what happened after all .1 point
-
If the parent page is hidden you'd have to include "include=hidden" in the selector when doing a find(), but not if you get() the page explicitly. Also wanted to note that doing $pages->get("title=previous caption winners")->children; isn't a very reliable method to find a page by it's title, since the title isn't unique. In most cases it makes more sense to use id or page name, page path. $pages->get(1005)->children; Or maybe $pages->get("/some/path/")->children; To find if a parent has children there's also a method in PW numChildren(). if($pages->get(1004)->numChildren) { // has children } In PW 2.3 there's a new version of numChildren() to make it access aware if you pass true as the argmument if($pages->get(1004)->numChildren(true)) { // has children that are really visible to the user }1 point
-
$cat = $sanitizer->selectorValue($page->title); // works $p = $pages->find("portfolio_categories*=$cat, template=portfolio, sort=-Project_Date"); This doesn't work because a page field doesn't work with operators and titles... as teppo explained. So you could imageine this: portfolio_categories*=mycategory could be seen same as: 1003|1004|1005*="mycategory" So you would need to give it a page id or a page array and PW will make the rest. portfolio_categories=$somecategorypage If you do echo $somecategorypage, the toString() method of page will output the id... So it would be like this now: 1003|1004|1005=1004 Or if you use a page array. echo $pageArray it will return a 1003|1004|1005 string which is usable also in a selector. 1003|1004|1005=1003|1004|10051 point
-
If portfolio_categories is a Page field, you can't and don't need to use '*=' or '%=', use '=' instead. In the case of Page fields '=' checks if the value of said Page field contains specified page, not if it's equal to it, so you should use that and a page ID (or Page object) to see if one of selected categories is the one you're looking for: // this should work: $cat = $sanitizer->selectorValue($page->title); $cat_page = $pages->get("template=portfolio_category, name=$cat"); $p = $pages->find("portfolio_categories=$cat_page"); // .. though in this case you should do this: $p = $pages->find("portfolio_categories=$page"); // .. and you could even do this: $p = $pages->find("portfolio_categories={$page->id}";1 point
-
Hmm, finished() still isn't being called. In Session::redirect() line 361: if(wire('process') == 'ProcessPageView') wire('process')->finished(); I did a var_dump(wire('process').'') and it looks like when you submit the Field editor form, wire('process') returns the Field instance you're editing - not the ProcessPageView instance. I'm currently using two hooks to work around this issue: $this->addHookBefore('Session::redirect', $this, 'flushChanges'); $this->addHookAfter('ProcessPageView::finished', $this, 'flushChanges');1 point
-
Hi, i had this problem and it is related with bugged blowfish in PHP older than 5.3.7. So if you generate password on newer PHP than 5.3.7 and move to older PHP you have this problem. Best suggestion is upgrade PHP. I temporary solved it this way.1 point
-
Thanks. In terms of similarity with Fredi, the main point is that they are both tools for editing content on the front end. Fredi is also an exceptional tool which I still use myself. Choose whatever best meets your requirements! In my opinion, the advantages to both are as follows: InlineEditor Advantages Extremely quick - no buttons to press and nothing special to do. Click an element to edit, click off once you're done. Page auto saves. That's it. This makes it perfect for sites that are mostly text based and for quick editing. You don't need to remember what field corresponds to which element on a site. Just click what you want to edit! Know exactly how your page will look before it is even saved - no nasty surprises! Utilizes modern technologies in browsers Fredi Advantages Works with all fields (I think?) Much, much better tested Literally pulls in the back-end editor to the front end in an iframe, making the save result fool proof Doesn't require the jQuery library Edit more than one field per-submit request Has a cooler and easier to remember name1 point
-
Hi ryan, I use 2.3.0 and I figured out something more about: useing the button it works fine in Firefox and Chrome, but not in IE10 (I restartet my System to close out to be a Cache-Problem). It´s angry, because if I make in Blog a Gallery and load i.e. 8 pictures, the page reload, all is ok, but after saving the (admin)page and reload there are 16 Pictures in the image-accordion. And another bug with IE10, when clicking a Picture in image-accordeon there should be a lightboxeffect to see the thumb greater, but in IE10 is only a lighter gray overlay and I only come back with IE10 back-arrow. Here in Austria we say the IE is a "hard dog", I have never seen a new Version of IE where not have been ugly Errors in dialogs or so that works fine before. I hope you can reproduce this in your IE10. Thanks for helping!1 point
-
You would have Sass (and/or Compass or whatever you prefer) installed and let your Grunt build script's watch task run it for you in the background. For me that's just it: Grunt can do so much more than just run a preprocessor. Yes, it needs some time to get into and get the hang of it, but once you've set up your Grunt tasks, it does practically everything but write code. And I'm sure the Grunt guys are going to figure that out as well one day.1 point
-
You'd want to hook after $pages->save(); If you want your function to execute on every page save, any time, then you'd want to create an autoload module. http://wiki.processwire.com/index.php/Module_Creation If you want to capture newly added pages separately, then you'd also want to hook $pages->added(), which is called after a new page has been added. This example shows both: /site/modules/HelloWorld.module class HelloWorld extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Hello World', 'summary' => 'Just an example module class.', 'version' => 1 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('save', $this, 'hookSave'); $this->pages->addHookAfter('added', $this, 'hookAdded'); } public function hookSave(HookEvent $event) { // this function called any time a page is saved (whether new or not) $page = $event->object; // now you can access anything from the $page } public function hookAdded(HookEvent $event) { // this function only called after a new page added $page = $event->object; } }1 point
-
I worked to make a module early this AM before everyone woke up, and have been banned from the computer since. But got a minute to post it so figured I would, and then I'll post a live example tomorrow. This is just a start on this module... lots more to cover obviously, but just wanted to get the momentum going. And it is fully functional even in this state, if anyone wants to try it out. I just experimented with simple forms having "name, email and message" text fields, so far. Here are usage instructions below (pulled from the module file), and the .module file is attached if anyone wants to try it or work with it. Just place it in: /site/modules/FormTemplateProcessor.module /** * Module to let you use templates as web contact forms. * * Can send you email and/or save the submission to a page in your site. * * Usage: * * 1. In admin, create the fields you want to be part of the form. * 2. Create a new template and assign your fields to this template. * 3. Create another template for your contact form page (if you don't already have one). * 4. Use the example below as a starting point for this contact form page: * * $form = $modules->get('FormTemplateProcessor'); * $form->template = $templates->get('my_contact_form_template'); // required * $form->requiredFields = array('fullname', 'email'); * $form->email = 'your@email.com'; // optional, sends form as email * $form->parent = $page; // optional, saves form as page * echo $form->render(); // draw form or process submitted form * * 5. Use CSS to style the fields. See the bottom of this file for suggestions. * */ Download at GitHub: https://github.com/ryancramerdesign/FormTemplateProcessor1 point