Leaderboard
Popular Content
Showing content with the highest reputation on 06/19/2015 in all areas
-
One way can be to not set an default icon to the template(s) but set it manually like here with other things: https://processwire.com/talk/topic/5609-display-a-template-icon-base-on-date-field/ I use this in a project where I need to show the workflow states and the current authors shortcut. There are used 3 different icons and 3 different colors. public function addHookAfter_ProcessPageListRender_getPageLabel($event) { $page = $event->arguments('page'); if ('aki-faq' == $page->template) { $iconTpl = $iconTpl1 = '<i class="icon fa fa-fw fa-file-text [_STATUS_]"> </i>'; $iconTpl2 = '<i class="icon fa fa-fw fa-check-circle-o [_STATUS_]"> </i>'; $iconTpl3 = '<i class="icon fa fa-fw fa-newspaper-o [_STATUS_]"> </i>'; if ($page->editStatus > 2) $iconTpl = $iconTpl2; if ($page->editStatus > 5) $iconTpl = $iconTpl3; $icon = str_replace('[_STATUS_]', 'editStatus' . $page->editStatus, $iconTpl); $kuerzel = str_pad($page->aki_bearbeiter->kuerzel, 3, ' ', STR_PAD_RIGHT); $bearbeiter = (0 == $page->aki_bearbeiter->id || false === $page->aki_bearbeiter) ? ' <span class="akiPageListItem kuerzel warning">---</span> ' : ' <span class="akiPageListItem kuerzel">' . $kuerzel . '</span> '; $event->return = $icon . $bearbeiter . $event->return; } }5 points
-
Hey, Been using this starter theme for a little while now and thought I'd open it up on github - https://github.com/benbyford/bb-starter It has all my favourite modules installed, .less, some hany .js libraries and a set of blog templates for a simple news / blog setup. The theme is built on the simple theme from PW with additional setup. For more info see the Readme.md file on github. See it here - http://bbstarter.nicegrp.com/ Thanks everyone for your continued work and fun using PW.3 points
-
Thank you horst, this is exactly what I was looking for. For those interested, this is my working module below, which adds in icons based on an select options field. <?php class DynamicIcons extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Dynamic icons for the page tree based on field values', 'version' => 1, 'summary' => 'Module to change the icon on the page tree depending on field values.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListLabelItems'); } public function addPageListLabelItems($event) { $page = $event->arguments('page'); $page->of(false); // Check options field for correct value if($page->content_type == '1') { // Add fontawesomeicon $styleItem = "<i class=\"fa fa-file-text-o\"></i>"; // Add to pagetree $event->return = $styleItem . $event->return; } } } (This just shows one options but obviously you could add in additional icons for different field values)2 points
-
HookAfterPagesSave - little things matter.2 points
-
The good thing of having it here intead of GitHub is that there could be it's own fine grained system for flagging, like in a project management system, so the people know the current status and where a voting would have an effect. - planned for this dev version cycle - panned for after next mayor update - Maybe sometimes - Not currently planned - Not planned (never) - Done/Closed (hidden?) (Maybe closed/done requests could be hidden and only shown on request) Just thinking...2 points
-
I was actually thinking of converting all feature request/enhancement issues to something in the PW website (powered by PW pages). Something like the sites directory, with the ability to "like" requests, so that the most requested ones could rise to the top and get more focus. This would also get them out of GitHub, so the focus there can be on issue reports. Though I think it's good to still submit feature requests at GitHub, but I would just move them to the more dedicated system and close them out there once that's done.2 points
-
Hi all This module was sponsored by Jason as per this topic: http://processwire.com/talk/topic/3566-email-image-module-development/ It's quite similar to horst & ryan's EmailImage module, but supports multiple email addresses for sending emails to different parts of your site, also allowing you to select different templates. There is also a delimiter option whereby you can split up the email's content and have text appear in the body or sidebar etc. Here's a video to show you what I mean. The video may well be of interest to other module authors as I used some Ajax to push what can normally be done in the module config - hope you like it There was the temptation to build on the EmailImage module with this one, but I already had code for my Helpdesk module (work in progress) that parsed emails using Flourishlib and wanted to use that code instead for this one. EDIT: Also worth noting is that unlike the EmailImage module, this doesn't come with a pre-built gallery template for the front-end. This is intentional as you could pipe emails into any part of a site you like, so I couldn't make assumptions as to usage of the content. You can download it via the modules directory.1 point
-
It would be awesome users could size their images for the RTE (rich text editor) using preset cropping sizes. This could really help ensure consistency across a site for editors that need to add images and reduce the amount of training needed when dealing with images. third part image crop fields do this really well, but do not offer a way to use the crops in the RTE. Image: Look next to the cancel button, there is a pulldown for image size presets. Drop down menus allows users the ability to select some preset image cropping dimensions. Crop guides would keep the aspect ratio, and return the desired image size. Pick custom size and the cropping guides would work as they normally do (free form) Other approaches: ProcessPageImageSelect could be made hookable in a way that images from third party image modules can add images to the RTE image selection page. i've been trying to get a preset image crop sizes into the RTE editor for a while now. I tried to use the hooks in ProcessPageImageSelect in-combination with the CroppableImage module but there is no hooks for this as (as far as I know). $this->addHookAfter('ProcessPageEditImageSelect::execute', $this, 'HookPageImageSelect'); The hook above will allow me to add images to the image selection modal, but I still can't get images that image to be addable to the Rich Text Editor on click. I was able to get the desired functionality by modifying core module ProcessPageImageSelect. Maybe if ProcessPageEditImageSelect->getImages() was hookable images from other modules could be added without modifying core modules.1 point
-
Hi, I wrote a new module this evening: Template Editor This module adds the possibility to edit and rename template files directly from the backend. Requirement: It's important to have this module installed and PW 2.2 running. Download: http://modules.proce...emplate-editor/1 point
-
It's just a simple typo diogo: // if this field doesn't exist continue if(!field) continue; You're missing the $1 point
-
It's not possible to filter style as an attribute in CKEditor this way. CKEditor works with this pattern: [attributes]{styles}(classes). Valid attributes are align or onclick for example, but style is handled with the second part of the pattern, in curly brackets. What you can do for example: [*]{width} will strip style="width:10px" from all elements. You can enhance this functionality with own JS functions. Read more about it in CKEditor docs1 point
-
Please try to not use uppercase writing. It's not that great to read. To answer the question: Use this to inject what ever logic you need just before a page gets saved. https://processwire-recipes.com/recipes/extending-page-save-process/1 point
-
What about Trello instead of or as well as? Some useful links: Going Public! Roadmapping With A Public Trello Board Software Developmentin Usage Examples1 point
-
If you split your foreach by html segments then it may be saver to use this syntax: <?php foreach($array as $item) : ?> … <?php endforeach; ?>1 point
-
I'm using 2.6.1. And the Hello World module works as expected. According to Ryans comments in the ProcessHello module, it's possible to use *.info.json or *.info.php.1 point
-
Martin, that is fixed already. I really need to figure out how to distribute upgrades... Can you send me an email and I'll send you latest release back?1 point
-
Pete, it's free for public repos. It's just another way to view and organize GitHub issues.1 point
-
Getting ready to launch. Needs some finishing touches but wanted to share it http://www.gabrielaestates.com1 point
-
Make sure to "open" the new parent page before moving stuff there. It needs to be highlighted to receive a page as child no matter if there are already children or not.1 point
-
Per Ivan's comment below, this will not work because PW won't throw a 404 for the root of the site - this was an oversight on my part, and I do apologise for that. As stated, I'll try and implement this when I rewrite the module. As an alternative, see my post below. Hi Dave Regarding Jumplinks, it would definitely come in handy - though I haven't release a final 1.0 yet. (Next few days, hopefully.) (Also, not compatible with 2.5.3.) You'd basically create a new redirect like so: Source: ?p={id} Destination: rewrite/{id} There's also the alternative, where you can map IDs to URIs (names) using mapping collections. You'd need to export your URIs from WordPress in the format below (one on each line) into to a mapping collection called, say, "wordpress". id=path Example: 1892=this-is-an-awesome-post Your redirect would then look like this: Source: ?p={id} Destination: posts/{id|wordpress} If a source pattern is hit, then it'll check the collection according to the ID provided, and replace it with the new name (posts/this-is-an-awesome-post, in this case).1 point
-
Hi Jay and thanks for the interest. What you are describing is not something I would recommend doing by using PadLoper product variations. In PadLoper each variation requires page id, so you can build variations using pages, repeaters or PageTable. That allows each product variation have their own unique price and stock. What you are after are more like perks or modifiers. Like additional services or modifications on product - which either increase or decrease the price and they don't have stock of their own. I have been thinking about that concept and will add those at some point, but you won't find them from first release. Although I am planning good hooks to make it possible to add things like that pretty easily with little custom coding per site.1 point
-
I need to output the content of a repeater field. Logged in as a super user everything works as expected: .. "matches":[{"id":1,"parent_id":1,"template":"repeater_example","path":"..","name":"..","content":"lorem ipsum dolor sit"," .. But when I'm not logged in, I get nothing. .. "matches":[]} Every other "normal" template works as expected, I guess the problem is the repeater template which has not the access to be viewed by guest users. The selector include=all is automatically added for superusers (wire ▸ modules ▸ Process ▸ ProcessPageSearch Line 271). include=hidden is not enough. Is there a way to enable repeater templates to be viewed by guest users? For now I use single pages instead of the repeater. But I need just one value per page. Any help would be appreciated1 point
-
Hi All, I have spent a decent amount of time over the last two days (starting yesterday on American Thanksgiving) rebuilding my main personal business photo site with Processwire. For now this project is still being developed on a local install of MAMP. I did not wake up yesterday with the intension of starting this project - but I just went for it... Going back a few months: I discovered Processwire by accident. I was not really looking for a new CMS to replace my weapon of choice, namely MODx. Processwire seemed intriguing, but to be honest I had serious reservations in the beginning. After some initial tire kicking my conclusion was "this looks like a really interesting alternative, but this system is for advanced developer geeks with skills, it might never be the playground for you..." Initially my commitment to Processwire was an awkward stop and go experience. But I stuck with it. I asked some basic questions that just screamed "newbie alert" but the constructive and helpful responses were rewarding. I began to take notice and found that overall the Processwire Forum was simply first class. I know my way around markup HTML, CSS and pushing pixels around. But I can't write scripting code like PHP to save my life. I thought this was going to be a deal breaker - but I stuck with it. Fast forward to today: I am amazed at how much I got done! I am taking an existing MODx site and converting/improving all the dynamic elements from MODx to Processwire. Along the way I am streamlining the markup, the CSS, the logic, while adding more efficient Processwire building blocks than I thought possible, all without needing to fire off "help me" requests to the Processwire forum. I am also improving my CSS skills and I am even beginning to feel less intimated with working with PHP code. I guess you could call this the Processwire "aha" moment. It just feels good! I am really enjoying working with this system. There is so much in the Processwire arena that is still a mirage in the sand, but I think that with time I will add more and more knowledge. I guess that is it. I really appreciate the help and encouragement from you all... Cheers, Max1 point
-
This is called the ProcessWire tractor beam. You've been pulled into its path! You wake up one day and know you won't be happy until your own site is completely rebuilt in PW. Even though you don't have time, you have real work to do and your current site and CMS have been perfectly "ok". Before you know it your life is full of echo statements, you're visiting the forums multiple times per day and you can't sleep at 5am because you're crazy excited about the great thing PW allowed you to do with your site that you never thought possible. Anyway, nice write up. Thanks for sharing1 point
-
Hi! Look for Custom Editor JS Styles Set in the field configuration and enter a path for .js file. In this file you can define your custom styles like this: CKEDITOR.stylesSet.add('mystyles', [ // Block-level styles { name: 'Heading 1', element: 'h1'}, { name: 'Heading 2', element: 'h2'}, { name: 'Heading 3', element: 'h3'}, { name: 'Introduction', element: 'p', attributes: { 'class': 'introduction'} }, // Inline styles { name: 'Link button', element: 'a', attributes: { 'class': 'button' } }, { name: 'Highlight', element: 'span', attributes: { 'class': 'highlight' } }, // Object styles { name: 'Stretch', element: 'img', attributes: { 'class': 'stretch' } }, ]); Also make sure you have Styles toolbar item enabled.1 point
-
You may do this by a module like that: public function init() { $this->addHookAfter('ProcessPageListRender::getPageLabel', $this, 'addPageListLabelItems'); } public function addPageListLabelItems($event) { $page = $event->arguments('page'); // then you do your conditionals and your styling, like for example: if($page->myField >= $myMinValue && $page->myField <= $myMaxValue) { // add your styling here } // or like that: if('architekt'==$page->template) { // add the styling here $styleItem = $page->ortarchitekt == '' ? ' <span class="jhpPageListItemEmpty"><strong style="color:white">kein Ort eingetragen</strong></span> ' : ''; // now add the new style item to the existing output $event->return = $event->return . $styleItem; } } This way I get outputs like that: EDIT: Ah, have found it: here is a module from Soma: http://modules.processwire.com/modules/page-list-image-label/ that adds a Thumbnail to the list. That was the startingpoint for my customized PagetreeList. If you are not (yet) familiar with modules please have a look to the HelloWorld-Module or ask here for further assistance1 point
-
You can also just check the page type within the hook function. By simply issuing a 'return' if it doesn't match the template you want, that duplicates the behavior of accessing an unknown property (resulting in a null value being returned to the caller). wire()->addHookProperty('Page::hello', function($event)) { if($event->object->template != 'basic-page') return; $event->return = 'hi'; });1 point
-
Would it be possible to have a module that allowed editing the actual page templates and css etc from the admin? Perhaps using something like http://ace.ajax.org/ That would be sweet!1 point
-
So, had same free time: https://github.com/NicoKnoll/TemplateEditor (just beta)1 point
-
That's a pretty nice code editor there, thanks for the link. Will have to take a closer look. For the most part though, ProcessWire assumes you have your own tools for editing things like your templates and CSS files, and is trying to stay out of your way in that regard. There are also some security issues with enabling direct editing of PHP files on the server. Though I still think this is a good idea for a non-core module, to provide editing capability of template files for those that want it.1 point
-
Hi @antknight, great to see a newer face on the forum so firstly: welcome! As with most things PW, the answer is almost certainly "yes" but in this case you'd probably be compromising the permissions on your template & css files in order to do it. I know that some other CMSs do have this kind of feature though (like Textpattern, which I like a lot.) Can I ask what your rationale for the request is? Do you need to develop on a live server or something? It might be that mounting the server partition locally over SSH would be both faster and more secure in such cases.1 point
-
When it comes to markup render stuff that is needed throughout the site, I also use that hook/module method mentioned above, adding new hook methods as needed to Page and PageArray. $events = $pages->find("template=event, sort=-date, limit=3"); echo $events->renderEvents(); Either that, or I'll just put them in a separate file and call them up with functions: include("./tools.inc"); echo renderEvents($events); If i'm making a lot of repetitive $pages->find() calls, I might also add a new hook method to $pages to serve as a filter so that I could do this: $events = $pages->events("limit=3"); I think that inheritance isn't ideal if all you need is to add some new methods to a class. While it works, it's adding another level of complexity, so I prefer to plug-in to things where possible, rather than extend them through inheritance. But what works for one doesn't necessarily work for all, and people have different preferences and ways of achieving things, so I would stick with whatever makes the most sense for your project. The inheritance of Page that you see in PW's core (like User, Permission, etc.) is more about having a separate type for typecasting purposes, than it is for extending functionality of Page. Though in PW's case, it does both. But if I didn't need separate typecasting (for argument type hints and such) then I might have utilized hooks for these instead. It was also a way to keep the system consistent with PW 2.0, which had User, Permission, Role classes that weren't Page objects. By making the new classes extend Page, it was a way to avoid potentially breaking older code that expected those types. As for implications, stuff that is in 'Advanced' mode is there because I don't really know the full implications. So if you find everything works, I think you are good. But the only implication I would be worried about is just what happens during upgrades and whether they are more likely to affect the approach you are using. I can't say for certain, as I don't totally understand the approach, but if it works now, it's more likely to continue working than not. That being said, the further you go in using a different approach from others, the more difficult it may be to troubleshoot when something doesn't work. Using an MVC approach with PW also doesn't need to be complex. If you think of your template files as PHP controllers, your $page(s) as your model, and use the TemplateFile class to render your views, you have an easy to use and implement MVC setup. There are applications where I like to use this approach. But for most web sites I find it more convenient and maintainable to use templates, modules and includes in a more traditional way. There are times when layers on top of markup makes things better, and there are times when it makes it worse.1 point
-
I would suggest changing that to: if($input->post->userid && isset($_FILES['imageUpload']['name'])) { But some concerns about your $userid variable (further down). This may not be specified enough. I'd suggest getting the $user first, and making the image_name be based on the user ID (perhaps with the time() component too, if you want it). Just a note here, but you want to be really certain that /site/tmpfiles/profiles/ is a non-web-accessible directory. Further in your code, you were adding it to PW with an HTTP URL, making me think it is web accessible. It's better to use PHP's move_uploaded_file() rather than copy, i.e. $copied = move_uploaded_file($_FILES['imageUpload']['tmp_name'], $newname); There is no authentication here, so any user can substitute another user's info in the POST vars... so the method you are using is not safe. But we'll get to that later. Lets assume for the moment that it was okay to include this in your POST vars (which it's not, but...) you would want to sanitize it differently. If that user ID is the user's ID number (i.e. integer), then you'd do this: $userid = (int) $input->post->userid; If it's the user's NAME (string) then do this: $userid = $sanitizer->pageName($input->post->userid); Also, after you get the $user, make sure that the user exists before adding stuff to it, like this: if(!$user->id) die("Invalid user"); Back to the security issue here. Since you are getting the current user from a POST var, it will be possible for any user to substitute another user's name or ID and change their photo. So I would suggest that you avoid using user ID's at all. You would only want to operate on a user that's already logged in. Or, if that's not an option, then you'd want them to provide their login and password as the user id rather than something else. If you are dealing with a user that's already logged in, you can do this: $user = wire('user'); No need to send that info in POST vars when it's already safely stored in the session. But if your situation is one where the user isn't going to be already logged in, then you'll want your front end form to have login and password inputs, and then get the user that way: <?php $u = $session->login($input->post->username, $input->post->pass); if($u->id) { // they can upload a photo } Before adding the image to your site, I would suggest making a resized copy of it just so that you are dealing with a real image and not something with anything fishy going on in the image format: <?php $filename = "../site/tmpfiles/profiles/$image_name"; try { // if image does not contain valid image data, the following will throw an exception $image = new ImageSizer($filename); // set some boundaries on the size of the image you are willing to work with $w = $image->getWidth(); $h = $image->getHeight(); if($w < 20 || $h < 20 || $w > 3000 || $h > 3000) throw new WireException("Image is out of bounds"); // overwrite old image with new resized version $image->resize($width - 10); // now add to the PW field $u->profilephoto->add($filename); // remove the original unlink($filename); } catch(Exception $e) { unlink($filename); echo "Error:" . $e->getMessage(); } Note that there's no need to specify the URL like this: That makes me think the filename is web accessible–make sure the uploaded files aren't web accessible until after you are certain all is good. When you are adding to PW, you can just specify the local filename rather than the URL (like in my example above). Don't bother with DOCUMENT_ROOT. Just use the same $filename as earlier. If you must have document_root, then use the one from PW instead: $config->paths->root1 point