Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/28/2017 in all areas

  1. Here is a little Hook that I use to add the last date of recurring events to the end of publication field. Please copy this piece of code into your ready.php file. //dates = name of your recurring field - please change it to your field name //publish_until = name of your end of publication field - please change it to your field name // hook to add the publish_until date according to the last event date $pages->addHookAfter('saveReady', function($event) { $page = $event->arguments[0]; if ($page->hasField('dates')) { $dates = $page->getDates(); if($dates){ foreach($dates as $key=>$date){ if ($key === key($dates)) $enddateunformatted = $date; } $page->publish_until = $enddateunformatted; $enddateformatted = date('d-m-Y', $date); $this->message($this->_("The end date of the publication was set to {$enddateformatted}.")); } } }); In my case I use the the SchedulePagesModule to unpublish pages after a certain date. In this case the date field for unpublishing pages is called "publish_until". My recurme field in this case is called "dates". You have to add both fields to your template. Now I want to copy the last date of the recurring events to the "publish_until" field, so that the article will be unpublished after the last recurrence. For this purpose you have to add the code above to your ready.php file. If you have named the fields differently than "publish_until" and "dates" you have to replace this by your names. In a first step I check if the template has the recurme field "dates". If yes then I check if there are events generated. The last step is to grab the last occurence and add this date to the end of the publication field ("publish_until") - finished! After pressing the save button the last ocurrence date will be saved in the publish_until field and the article will be unpublished after this date. Best regards
    4 points
  2. Same story, different country haha. There is not a ListerPro "skin" . So assuming from the type of client yo you are dealing with, you'd be better off satisfying their UI/UX needs, or at least what they are used to. Because you're gonna end up fighting PW's markup and overriding it's styling. and end up with a bloated thing rather than the elegant solution ListerPro is meant to be. Customising the admin is easier now with the new UIKit based theme. But truly, here is where PW shines its brightest, leveraging the selector API makes building a lister pretty straightforward, I mean, the screen you post is basically a graphic description of what the selector API can do. So from what you mention about the project you are involved in, just build the thing and make people happy If you manage to reuse that frontend in the screenshot, it's basically just getting the data from the front to the back and let PW do the rest.
    3 points
  3. Welcome @FlorianA, There is module in the directory that provides a Inputfield/Fieldtype for picking and storing time values: http://modules.processwire.com/modules/inputfield-time/
    2 points
  4. @ryan, I want to let you know I really admire the way you get things done! Every time you solve a problem it is an example of a perfect engineer solution. Spot a chance to create a feature everybody wants but few have, examine existing solutions present, learn from them, build on them, make them work better than before, deliver a working feature within a reasonable time frame, provide comprehensive docs right there in the code for tech people, write a press release for the end users, move on to another task. Way back I once started a topic called "What is "Reiska". I think now I can feel what @apeisa and others at Avoine meant by this title. There is such a word in every language, and all of them fit you and your type of people (of which there is quite a few here in forums, luckily). I sometimes find myself questioning some of your marketing and organizational decisions, but I always applaud to and try to learn those problem solving skills and mindset from you. ProcessWire is unique thing, that inspired my way from "anykey clicking" web development to managing to read and write some relatively complicated code. I try hard to provide my clients with the best engineer solutions they can get based on ProcessWire. Because I can, and because it so exiting to do with PW, and because this is the way real stuff should be done. Thanks for the inspiration.
    2 points
  5. I have had this module sitting in a 95% complete state for a while now and have finally made the push to get it out there. Thanks to @teppo for his Hanna Code Helper module which I referred to and borrowed from during development. http://modules.processwire.com/modules/hanna-code-dialog/ https://github.com/Toutouwai/HannaCodeDialog HannaCodeDialog Provides a number of enhancements for working with Hanna Code tags in CKEditor. The main enhancement is that Hanna tags in a CKEditor field may be double-clicked to edit their attributes using core ProcessWire inputfields in a modal dialog. Requires the Hanna Code module and >= ProcessWire v3.0.0. Installation Install the HannaCodeDialog module using any of the normal methods. For any CKEditor field where you want the "Insert Hanna tag" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "HannaDropdown" to the "CKEditor Toolbar" settings field. Module configuration Visit the module configuration screen to set any of the following: Exclude prefix: Hanna tags named with this prefix will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Exclude Hanna tags: Hanna tags selected here will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Background colour of tag widgets: you can customise the background colour used for Hanna tags in CKEditor if you like. Dialog width: in pixels Dialog height: in pixels Features Insert tag from toolbar dropdown menu Place the cursor in the CKEditor window where you want to insert your Hanna tag, then select the tag from the "Insert Hanna tag" dropdown. Advanced: if you want to control which tags appear in the dropdown on particular pages or templates you can hook HannaCodeDialog::getDropdownTags. See the forum support thread for examples . Edit tag attributes in modal dialog Insert a tag using the dropdown or double-click an existing tag in the CKEditor window to edit the tag attributes in a modal dialog. Tags are widgets Hanna tags that have been inserted in a CKEditor window are "widgets" - they have a background colour for easy identification, are protected from accidental editing, and can be moved within the text by drag-and-drop. Options for tag attributes may be defined You can define options for a tag attribute so that editors must choose an option rather than type text. This is useful for when only certain strings are valid for an attribute and also has the benefit of avoiding typos. Add a new attribute for the Hanna tag, named the same as the existing attribute you want to add options for, followed by "__options". The options themselves are defined as a string, using a pipe character as a delimiter between options. Example for an existing attribute named "vegetables": vegetables__options=Spinach|Pumpkin|Celery|Tomato|Brussels Sprout|Potato You can define a default for an attribute as normal. Use a pipe delimiter if defining multiple options as the default, for example: vegetables=Tomato|Potato Dynamic options Besides defining static options as above, you can use one Hanna tag to dynamically generate options for another. For instance, you could create a Hanna tag that generates options based on images that have been uploaded to the page, or the titles of children of the page. Your Hanna tag that generates the options should echo a string of options delimited by pipe characters (i.e. the same format as a static options string). You will probably want to name the Hanna tag that generates the options so that it starts with an underscore (or whatever prefix you have configured as the "exclude" prefix in the module config), to avoid it appearing as an insertable tag in the HannaCodeDialog dropdown menu. Example for an existing attribute named "image": image__options=[[_images_on_page]] And the code for the _images_on_page tag: <?php $image_names = array(); $image_fields = $page->fields->find('type=FieldtypeImage')->explode('name'); foreach($image_fields as $image_field) { $image_names = array_unique( array_merge($image_names, $page->$image_field->explode('name') ) ); } echo implode('|', $image_names); Choice of inputfield for attribute You can choose the inputfield that is used for an attribute in the dialog. For text attributes the supported inputfields are text (this is the default inputfield for text attributes so it isn't necessary to specify it if you want it) and textarea. Note: any manual line breaks inside a textarea are removed because these will break the CKEditor tag widget. Inputfields that support the selection of a single option are select (this is the default inputfield for attributes with options so it isn't necessary to specify it if you want it) and radios. Inputfields that support the selection of multiple options are selectmultiple, asmselect and checkboxes. You can also specify a checkbox inputfield - this is not for attributes with defined options but will limit an attribute to an integer value of 1 or 0. The names of the inputfield types are case-insensitive. Example for an existing attribute named "vegetables": vegetables__type=asmselect Descriptions and notes for inputfields You can add a description or notes to an attribute and these will be displayed in the dialog. Example for an existing attribute named "vegetables": vegetables__description=Please select vegetables for your soup. vegetables__notes=Pumpkin and celery is a delicious combination. Notes When creating or editing a Hanna tag you can view a basic cheatsheet outlining the HannaCodeDialog features relating to attributes below the "Attributes" config inputfield. Advanced Define or manipulate options in a hook You can hook HannaCodeDialog::prepareOptions to define or manipulate options for a Hanna tag attribute. Your Hanna tag must include a someattribute__options attribute in order for the hook to fire. The prepareOptions method receives the following arguments that can be used in your hook: options_string Any existing string of options you have set for the attribute attribute_name The name of the attribute the options are for tag_name The name of the Hanna tag page The page being edited If you hook after HannaCodeDialog::prepareOptions then your hook should set $event->return to an array of option values, or an associative array in the form of $value => $label. Build entire dialog form in a hook You can hook after HannaCodeDialog::buildForm to add inputfields to the dialog form. You can define options for the inputfields when you add them. Using a hook like this can be useful if you prefer to configure inputfield type/options/descriptions/notes in your IDE rather than as extra attributes in the Hanna tag settings. It's also useful if you want to use inputfield settings such as showIf. When you add the inputfields you must set both the name and the id of the inputfield to match the attribute name. You only need to set an inputfield value in the hook if you want to force the value - otherwise the current values from the tag are automatically applied. To use this hook you only have to define the essential attributes (the "fields" for the tag) in the Hanna Code settings and then all the other inputfield settings can be set in the hook. Example buildForm() hook The Hanna Code attributes defined for tag "meal" (a default value is defined for "vegetables"): vegetables=Carrot meat cooking_style comments The hook code in /site/ready.php: $wire->addHookAfter('HannaCodeDialog::buildForm', function(HookEvent $event) { // The Hanna tag that is being opened in the dialog $tag_name = $event->arguments(0); // Other arguments if you need them /* @var Page $edited_page */ $edited_page = $event->arguments(1); // The page open in Page Edit $current_attributes = $event->arguments(2); // The current attribute values $default_attributes = $event->arguments(3); // The default attribute values // The form rendered in the dialog /* @var InputfieldForm $form */ $form = $event->return; if($tag_name === 'meal') { $modules = $event->wire('modules'); /* @var InputfieldCheckboxes $f */ $f = $modules->InputfieldCheckboxes; $f->name = 'vegetables'; // Set name to match attribute $f->id = 'vegetables'; // Set id to match attribute $f->label = 'Vegetables'; $f->description = 'Please select some vegetables.'; $f->notes = "If you don't eat your vegetables you can't have any pudding."; $f->addOptions(['Carrot', 'Cabbage', 'Celery'], false); $form->add($f); /* @var InputfieldRadios $f */ $f = $modules->InputfieldRadios; $f->name = 'meat'; $f->id = 'meat'; $f->label = 'Meat'; $f->addOptions(['Pork', 'Beef', 'Chicken', 'Lamb'], false); $form->add($f); /* @var InputfieldSelect $f */ $f = $modules->InputfieldSelect; $f->name = 'cooking_style'; $f->id = 'cooking_style'; $f->label = 'How would you like it cooked?'; $f->addOptions(['Fried', 'Boiled', 'Baked'], false); $form->add($f); /* @var InputfieldText $f */ $f = $modules->InputfieldText; $f->name = 'comments'; $f->id = 'comments'; $f->label = 'Comments for the chef'; $f->showIf = 'cooking_style=Fried'; $form->add($f); } }); Troubleshooting HannaCodeDialog includes and automatically loads the third-party CKEditor plugins Line Utilities and Widget. If you have added these plugins to your CKEditor field already for some purpose and experience problems with HannaCodeDialog try deactivating those plugins from the CKEditor field settings.
    1 point
  6. Client-side image resizing has been on our roadmap for awhile, and this week we've got it ready on the dev branch in version 3.0.63. People expressed interest in this feature in the comments to last week's post, and I promised to give it a closer look sooner rather than later. After getting that closer look, and doing some research, I realized we could get in this week's version. After using it now for a couple of days this week, I think people are really going to like this feature, and it works a lot better than I had originally guessed it could. https://processwire.com/blog/posts/processwire-3.0.63-adds-client-side-image-resizing/
    1 point
  7. Hi all, I'm new to Processwire, I just wanted to say thanks Martijn for this step by step guide. I would highly recommend this to any Mac user getting started with Processwire. I also followed these steps for using Gmail as the mail server. I would say the benefits of following a manual install (for a noob in terms running a local server) are high. I've now learned HOW the configuration works, and where the settings are stored, rather than running an install process. Thanks again! Dave
    1 point
  8. Hey @tpr, Thanks for the module. Switched over from Twig and really enjoying the custom filters, makes things much easier. Just wondering about embedding a Form Builder form. As Form Builder creates a form-builder.php template which gets called via Ajax when embedded in another template, I am running into issues for obvious reasons (no .latte view file etc.). I know there are workarounds and different form builder options, but for this use case I feel like am missing something, like the ability to bypass the view or turn latte off on a template basis. Thanks again.
    1 point
  9. Normally there cannot be a duplication of the sort index for the same pages_id. Before an Imagefield is stored all page related entries (pages_id == $page->id) are deleted first from the database before the new sorted images are stored (@see /wire/core/FieldtypeMulti.php) .Try to clear manually all related entries from the database and try again.
    1 point
  10. @Chamche First of all, ask your hosting provider to turn off ModSecurity, or they should let you know the .htaccess rule(s) that need to be added to the beginning of .htaccess. There is no need for mod_security if you use ProcessWire with the .htaccess file it comes with.
    1 point
  11. @Twitch Could it work to have the whole PW admin area as guest area (if it's in a private network, no problem I guess?) and just use the ListerPro out of the box. You would have to build the other admin pages (if in need of something customizable) as Process modules. The picture you show looks different but basically those are the type of options you are given when using ListerPro filters. I guess you could do something like this on the frontend but with the Process module involving ListerPro. (ProcessListerPro?). Though you would have to include js/css for the ListerPro to work (and it would LOOK like a PW ListerPro). Also don't really know how ListerPro internally checks permissions or any other gimmick involving routes in the pw admin.
    1 point
  12. Years later we have more options) There is a special module by @ryan for that now. You can also do a backup from cli with wireshell. There is a nice module by @flydev still in the way, but looking promising. Look here for some discussion and 3rd party tools.
    1 point
  13. The good reason here is being a content-management system and not a layout-factory of sorts. It's there to store content, while being concerned as little as possible about whichever way the content will be served to the user. This is up to the developer to decide/implement. In fact it's rather the opposite. E.g. drupal is recently trying to shift more towards being a potentially headless cms, which is not coupled to any kind of output strategy (html+css is only one possibility). With the shift to more and more content being served over multiple channels at the same time (website + api / website + mobile app / …) it's also needed to have this freedom. But as I said it always depends on the individuals situation. If you need something to click together the layouts in the backend ProcessWire might not be the best fit.
    1 point
×
×
  • Create New...