Leaderboard
Popular Content
Showing content with the highest reputation on 09/22/2013 in all areas
-
since you are using api already, try this right after your save: $p->name = $p->id; $p->save();3 points
-
Since your values appear to be integers, you can sanitize them as easily as: $sanitizedValue = (int) $t; That sanitizes, but doesn't validate the value. Validation is also important, especially with something like an ID number that indicates a reference to something else. This is even more important in ProcessWire, where page IDs can also represent things like users, admin pages and more. To validate, you'd want to make sure the number is valid for the selection. To do this, you'd need to confirm that the value you were given was present in the list of selectable options you gave to the user. Or, if you know the selection is limited to pages from a certain parent or template, you could validate like this: $p = $pages->get($sanitizedValue); if($p->id && $p->template == 'your-valid-template' && $p->parent->id == 123 && $p->viewable()) { // it is valid } else { // it is not valid }3 points
-
Hi Guys, I've decided to share my work on a Fieldtype for adding star ratings to page items. I used @apeisa's FieldtypePoll as a starting point. Check out the readme on github for usage: https://github.com/jdart/FieldTypeRate I've got a couple screenshots that should demonstrate the functionality. Feel free to give me any feedback. Regards, Jonathan2 points
-
Thanks gentlemen. Ryan - would it be difficult to add a shared modules directory that ProcessWire could be configured to look for? Something like: /wire/ /modules/ /site/ /site-example1/ /site-example2/ Perhaps you could add a preference in "/index.config.php" , since that's where you'd set up the domain routing for multiple sites anyway? That way, the default single-site install doesn't have the overhead/complexity, but a multi-site install could take advantage?2 points
-
@Macrura: first of all, if you've enabled HTML Entity Encoder, make sure it comes in after, not before, Hanna Code textformatter. The code snippet you posted earlier works just fine for me, so I'm guessing something else is wrong.. most likely another textformatter messing with markup before it gets sent to Hanna Code. If that doesn't solve your problem, try debugging your snippet, ie. what's the actual attribute value in there.2 points
-
No problem–it is now hookable on the dev branch. Ok, I think I understand now (It's using the page title rather than the module title). These are translatable by making the title field multi-language. But it'd be better to just bundle them in with the language pack since they are core modules, so we can add this to the default.php template, no problem. I'll add that. I have no idea what this could be. We don't serialize any objects with sleep/wakeup. It sounds like there must be some other code doing this, but who knows where. I would look at your 3rd party modules and any other code you might be including in your site. Also, double check that you entirely replaced your /wire/ directory when updating (removing or renaming old /wire/, and creating new one). I've not been able to duplicate this one. But what you are describing points to a JS error occurring. Open up your JS console and check for errors. If you don't see any, go to the "network" tab and click on the page list ajax request. In the "response" you'll probably see some error message above the JSON code for the response. You get an endless loading arrow because the response isn't valid JSON, but looking at the response should quickly answer what the problem is.2 points
-
Try adding this to the top of your /site/templates/admin.php, after the opening <?php tag: $pages->addHook('saveReady', null, 'makePageHidden'); function makePageHidden(HookEvent $event) { $page = $event->arguments(0); if($page->template != 'category-site') return; // replace 'category-site' with your template name if(!$page->is(Page::statusHidden)) $page->addStatus(Page::statusHidden); }2 points
-
The deleteAll() is actually a queued call that occurs when the page is saved. As a result, you might need to add $page->save() right after the deleteAll() call, just so that it doesn't end up deleting the newly added image too.2 points
-
Limiting by IP or cookie both have their drawbacks. You can imagine an office with 100 workers all behind one ip address. Cookies can also be deleted. For my needs the implementation is good enough, but if you really wanted to prevent bots taking advantage you'd require users to be logged in to vote. That being said the voted detection could be a lot more sophisticated.2 points
-
I thought I'd start this thread so we could all share our favorite debugging techniques. The idea for this came from this post by Soma: http://processwire.com/talk/topic/4416-delete-user-when-page-is-deleted/?p=43320 and some of the followups with other suggestions. Here's one that I find really useful. It allows you to output content to the browser's console from PHP. It sends content from PHP through javasacript's console.log(); Not as powerful as FirePHP etc, but simple and easy to use. Put this function somewhere that it will be available to all your template files. function debug ($data) { echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}"; $output = explode("\n", print_r($data, true)); foreach ($output as $line) { if (trim($line)) { $line = addslashes($line); echo "console.log(\"{$line}\");"; } } echo "\r\n//]]>\r\n</script>"; } Then you can simply put these anywhere in your templates: debug('test'); debug($variable); debug($array); This keeps your page content clear of debug messages and is easier then looking in log files, like if you were to use error_log() What are your favorite techniques?1 point
-
Hi Guys, I'd like to share a module the development team at metric marketing and I came up with. I have a lot of experience with the Symfony framework, and when working with PW I came to miss some of the practices I grew accustomed to when working with PW. This module is aimed at bridging my previous experience with doing things to PW way. I have a big readme on the github project so be sure to check that out to get all the details: https://github.com/jdart/Spex From the readme "The project makes use of lessphp, less.js, jQuery, modernizr, Minify and the ProcessWire Minify Module." There's an example site in the github repo that illustrates how Spex works: https://github.com/jdart/Spex/tree/master/example-site In short your template file isn't responsible for including the head and foot etc... and instead is injected into a layout. In addition to this is adds some conventions for adding css/less/js to the page so that it can be combined and minified. Have a look through it and let me know if you have any feedback.1 point
-
Here's an example of the performance boost I gained by doing this... My page was 26kb before, and 4kb after. Page loading time was reduced by almost half. In site/config.php uncomment $config->prependTemplateFile and $config->appendTemplateFile = '_out.php'; /** * prependTemplateFile: PHP file in /site/templates/ that will be loaded before each page's template file * * Uncomment and edit to enable. * */ $config->prependTemplateFile = '_in.php'; //you can name this file whatever you want /** * appendTemplateFile: PHP file in /site/templates/ that will be loaded after each page's template file * * Uncomment and edit to enable. * */ $config->appendTemplateFile = '_out.php'; //you can name this file whatever you want Create two new files in site/templates called _in.php and _out.php. In _in.php add the following at the top of the file (before any code that you add later) <?php if (!in_array('ob_gzhandler', ob_list_handlers())) { ob_start('ob_gzhandler'); } else { ob_start(); } ?> In _out.php add the following at the bottom (after any code you add later) <?php ob_end_flush(); ?>1 point
-
1 point
-
thanks! that did it. I tried to manipulate $p->path but with no luck. completely missed $p->name. never crossed my mind to look there. I guess $p->title is used to populate $p->name which is used to create $p->path? Am I getting it right?1 point
-
Good call diogo! Ideally the admin theme should be shared too. Maybe something more like this then: /wire/ /shared/ /modules/ /templates-admin/ /site/ /site-example1/ /site-example2/1 point
-
1 point
-
@teppo - thanks, i finally got it to work, i had to decode the > and < signs, that's what i was wondering about with hanna code and why i originally was asking about using comparison operators like > and <, since in the editor they get encoded and that's why the selectors were not working... i just had to add this line and it works now: if($range) $range = html_entity_decode($range);1 point
-
Hey Marty, If they're not logged in, then I think the only reliable option will be cookies. You just need to store the ID of the PW page that stores the property's details. You could store these in one cookie as a comma separated list. I have done this with an an image library application so that guest users can create a lightbox of images. You could get a little fancier and allow them to create more than one group of properties too. Let me know if that helps, or if you'd like I can grab some non-PW bits of code as examples of how to store and retrieve the IDs. I am sure you know this, but remember that you can use both PHP and JS to manipulate cookies, so you can save changes to their list of properties without needing a page refresh. Just make sure the expiry of the cookie is set to a year or something like that. Hope that provides a starting point.1 point
-
Next to this, wrapping block elements in links, can reduce markup, create a bigger click area & you get a styleable container for free This is great!1 point
-
Martijn is correct, and this profile is written for the HTML5 spec. I think there are a few more examples of the same thing in this profile as well.1 point
-
Hey diogo! Great way to explain the ProcessWire data structure by making analogies to universal data-relations concepts! Thanks, Matthew1 point
-
I don't think there is any disadvantage besides the upgrading.1 point
-
Hi Gabi, There's no difference between calling ->field or ->get('field'); First is routed through PHPs magic getter ( __get() ) and will call the get() method behind the scenes... If you want to have global variables available all the time, why not just store them in a variable, e.g. $global? No need to assign them to the actual $page variable: // Store page in $global or $sys $global = wire('pages')->get(1222); // Later in any template... just get the values from your variable echo "<div id='contact'>{$global->contact_name}</div>";1 point
-
Hi Emmanuel and welcome to PW. PW does not control the frontend code at all, you have complete flexibility to write the output exactly as you need, including the adding of form labels. As an example, there are different ways to do this, but if you are using PW's built-in method for generating forms, you can do something like: $f->name = "myField"; $form->label = __("Field Title"); Obviously you need to build the other elements of the form, but you get the idea. You can of course use normal HTML: <label for="myField">Field Title</label> The advantage to the first approach is that the label can be made translatable using PW's language support. You can use Bootstrap, or any other framework you wish. Ryan has recently developed a Zurb Foundation profile for PW, but it is not too difficult to use any of the other frameworks. http://modules.processwire.com/modules/foundation-site-profile/ http://processwire.com/talk/topic/2411-bootwire-basic-twitter-bootstrap-profile/ http://processwire.com/talk/topic/3832-release-unsemantic-site-profile/ PW supports multilanguage: http://processwire.com/api/multi-language-support/ You can always access the database directly. It is a standard MySQL database so you can view it easily with something like PHPMyAdmin. You can also of course query it directly using SQL statements, but in most cases using PW's API and selectors is much easier. Hope that helps get you on your way to CMS nirvana1 point
-
My suggestion is to use the last LTS (long term support) version of Ubuntu, right now is 12.04. The documentation in Linode is very good, follow along with their "Getting started" tutorial and you should be fine.1 point
-
Thanks adrian! I actually thought I had fixed that months ago... And I had, but the changes unfortunately never made their way into GitHub until now. Anyways, multi-lingual titles are now fixed. Also, I pushed a little new feature as well: now you're able to choose a role and page permissions are shown for that role for each listed page. Hovering those yes/no texts gives a short explanation (as the titles are just single letters to keep it compact).1 point
-
I'd like to see this module get some love, so if someone wants to help Antti, I can donate a couple of hundred euros.1 point
-
Log in in with email address has more overhead so shouldn't be default. Please let the system as it is. ( think ryan won't change it, cause it makes sense ) If your needs for the login with email is that high, write a module for it that hooks in. ( Session authenticate ( not shure about this hook ) ) side note: There are a lot of developers to overcomplicate scripts. (count my self in) Ryan is the gatekeeper of no overhead & simplicity. let it be this way, please1 point
-
Never trust user input. So yes, you should sanitize user submitted values.1 point
-
Thank you both. Both answers solved my issue. I resolved it like this: foreach($input->post->type as $t) $p->sale_type_select = $t; Having read a number of other posts I'm trying to keep in mind validation, could I potentially run the post through the sanitizer function?1 point
-
HTML5 specs are different. In HTML5 it's allowed to wrap block level elements with links. this is valid: <a href='/link/to/page.html'> <div> <h1>I'm</h1> <p>Allowed</p> </div> </a>1 point
-
Firstly, you need to make the name of the checkbox field an array by appending [] echo "<input type='checkbox' name='type[]' value='{$t->id}'>{$t->title}<br>"; Then take a look at Ryan's example: http://processwire.com/talk/topic/3061-how-to-save-field-page-type-checkbox/?p=302291 point
-
If I understand your code correctly, $input->post->type will be an array (http://php.net/manual/en/language.types.array.php), consisting of 0 or more selected Sale Type id's, so you'll need to foreach through them at each stage of processing the form input.1 point
-
Actually, Andrew, I have just realised the above may not be what you want. The above limits how many characters you can type. If on the other hand, you are looking for something that will trim the amount of text entered to a certain number, there was some code posted here on the forums but can't find it at the moment... Here it is, by Ryan http://processwire.com/talk/topic/22-how-to-build-a-news-page/?p=511 point
-
TEXTAREA COUNTER http://modules.processwire.com/modules/textarea-counter/ http://processwire.com/talk/topic/2343-char-counter-for-texttextarea-fields/ Source Code: https://github.com/boundaryfunctions/TextareaCounter TextAreaCounter.module: https://gist.github.com/somatonic/4252958 TextAreaCounter.js: https://gist.github.com/somatonic/42529621 point
-
Scaling should happen on later time, on template level I think. (Don't mess up the originals) code for your template: $images = $page->images; // assumed that the field called images if(count($images)) { foreach($images as $image) { $width = $image === $images->first ? 600 : 200; $thumb = $image->width($width); echo "<img src='{$thumb->url}' alt='{$thumb->description}' />"; } } This should work, didn't test it.1 point
-
Well, I see two in your picture, which one is Martijn and which one is Geerts?1 point
-
I'm glad you will be sticking with us Here is the A-B-C: http://processwire.com/api/ http://processwire.com/talk/topic/693-small-project-walkthrough-planets/1 point
-
@RIVO I love to hear this: For the moment I'll stick to PW for my personal projects and learning. You won't regret learning a little PHP. Even if you leave PW, the knowledge is there, ready to use everywhere.1 point
-
Wow! So many useful replies already! @ pwired - thanks for posting those links! Very useful to start with! @ Martijn Geerts - kinda true, PW has more basic features than many of orher cms (but not instantly applicable). Thanks for Font Awesome suggestion @ diogo - Thanks for your patience and suggestions. Very good tips, it will help for sure! Form Processor is good for start, Ryan's template is Awesome Your replies are very "refreshing", they reinforce my initial feeling that PW has so much potential! It looks like PW offers Great Rewarding with Little Learning. So I should do the learning. For the moment I'll stick to PW for my personal projects and learning. Well, I guess it just sounds that way. As I said, my mind doesn't really get it yet but my heart (unconscious mind) loves PW. I trust my unconscious mind! And I am very happy this forum has so many skilled and helpful guys. Thanks all for replies. I will start with A-B-C. Thanks! I'am glad I found PW and this Forum! Have a nice day!1 point
-
Yes, it is possible and has been done. I am in a hurry so can't go into details but there are at least two examples in the forum. One, a bookmarking app by Jonathan and the other an Intranet app. No code examples for the above two, atm..but, yes, it can be done See also Diogo's Admin Custom Pages module. You can also do this by creating your own Process Module.1 point
-
If the report will end up being a page in the admin you might as well do this in #2 by creating a page then. Since a page's data is also stored in the db, why have a db entry (page) for the report (#4) as well as another db entry for the form (#2)? Anyway, I don't know your exact needs. As for exporting to PDF, there is a module for that. Check the modules directory. Have a go at the code in the links I posted above then we can take it from there if you get stuck. Bottom line is you will need to use: $input->post (assuming you are not creating a multi-dimensional array; in such a case, you would use PHP's $_POST) to handle the form data $sanitizer - to sanitize your data. You can also (additionally) use client side validation just to make sure emails are formatted correctly, etc. new Page to create and save new pages based off your form input data PW db class if you want to save your form data to custom db tables. You can also use PHP msqli or PDO. If using custom tables, you will need to create this either using PHP or directly in phpMyAdmin or similar An email class to send your emails I might have forgotten something...1 point
-
@RIVO, I'm as surprised as you that you still keep coming back to ProcessWire. It really sound that this is not the tool you are looking for. That said, I will try to explain why PW is not as "usable" as others by listing some points. Flexibility (first and last point on the list)----- PW as a very well defined kind of user: coders (and willing to learn non coders) that look for extreme flexibility. The fact there there aren't many built in features makes it possible that (with some work, but not a lot) things will be exactly as you want them to be. It can seem a bit scary at first, but if you actually try to use the API you will understand how intuitive it is and how easy it is to come up with several ways of quickly building the features that you mentioned. Anyway, I can't say I agree with PW lacking those many basic features. Let's go through them one by one: There is a module for basic contact forms http://modules.processwire.com/modules/form-template-processor/. If this is too basic there's always Ryan's excellent form builder http://modules.processwire.com/modules/form-builder/ Really?? TinyMCE is exactly the same as in Wordpress and many other CMSs and there are plenty of instructions around the forum to extend it with buttons and plugins. If you prefer CKEditor (as I do) and are not able to install it, just ask in the forums, and I'm sure we will figure out what's happening. What do you mean? A frontend gallery? There are plenty javascript plugins for galleries. The advantage is that PW let's you easily use any of them. Here's is a tutorial on how to implement one of those (flexslider) http://wiki.processwire.com/index.php/Simple_Gallery_System. Please read http://processwire.com/api/multi-language-support/multi-language-urls/ Again, flexibility, flexibility, flexibility... PW will never touch your frontend code (plugins might do it, but not the CMS itself), you'll have to build the page yourself (use dreamweaver or an html template if needed), and in my opinion PW is by far the easiest and most flexible tool for doing it. Welcome to the forum1 point
-
Now also powered by ProCache - thanks a lot for your help with our quirky hosting environment Ryan! The work you put in on PW, and to help us get it to work to the fullest of its fantastic potential is nothing short of amazing! I would urge everyone that haven't already done so, to try this plugin, and in minutes release the speed potential of the sites we put so much time and effort into creating.1 point
-
I would say: ProcessWire has more basic features then any other CMS out there that I know. ( but it's not a one two three, click, click: I have a new website ) In other CMSses you have to learn a lot of things to (maybe it doesn't look like code, but it is). But when you switch to an other CMS your Knowledge is gone. I don't want to invest in a unsure future. Who can say that the big 3 will be the big three within 3 years. If you don't want to code at all. I think it's better to not a CMS at all. There are plenty of website builders for Mac or PC.1 point
-
This classic thread started by Matthew will get your started with #2 and #3 (validation = sanitization + correct input) http://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/ PW $input variable: http://processwire.com/api/variables/input/ Great form examples in Soma's Gist: https://gist.github.com/somatonic1 point
-
Greetings, There are so many possibilities it's hard to suggest! When I am hunting for design ideas, I have a list of sites I go to for inspiration. Some have great categories and interesting ways of searching that help you even more. Just a few examples: Site Inspire (Even More specific for you: charity site samples) Design Bombs Awwwards CSSElite Design Shack CSSLine Creattica Thanks, Matthew1 point
-
Thanks Ryan, I have just updated the module on the module's page with v1.0.3. This version moves many of the settings to the module configuration page, rather than on a per field basis. I dealt with the leading zero issue by appending a tilde on settings save and removing it when loading the settings, so it is transparent for the user. I have also update the instructions in the first post above. If anyone has any changes they'd like to see, please let me know.1 point
-
Good job! Thanks for the tip. Please note, people, that before implementing this you must check your PHP zlib configuration. Because the official PHP documentation states that To check, either run php -i | grep zlib.output_compression if you are on a console, or do the usual phpinfo() thing and search for zlib.output_compression. To note the obvious: if you are using PW 2.3.0, the default file names are: $config->prependTemplateFile = '_init.php'; and $config->appendTemplateFile = '_done.php'; With the almost untouched default site profile, I got 34 kbytes without uncompression vs 8 kbytes with compression (page /about/; traffic measured with Comodo Dragon (based on Chromium). Screenshots are attached). One last remark: the PHP docs recommend turning on zlib.output_compression. Which is understandable once you start taking PW caching into account.1 point
-
Tnx ryan. Had a hard fight building this module with scoping as i'm not very comfortable with OOP. I needed some functions to be static ( for getModuleConfigInputfields ). It was a bit of trial and error. All points you mentioned are fixed in the latest update. What is still unclear to me is why this module still needs a empty init() to function.1 point