Leaderboard
Popular Content
Showing content with the highest reputation on 03/25/2017 in all areas
-
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.13 points
-
One of my older module just got some love! So, just wanted to mention that the Module was updated to v2.0.0 with some changes. 1. Its now compatible with PW2.4+ and PW3+. 2. Some changes were made to how it works. It was replacing core function to create the page list labels thus some newer features were missing. Which was kinda pain in the ***. Now it's just hooking after and prepends the image. Done. 3. It also now is not enabled/configured through the template custom label anymore. You can configure templates via a textfield on the modules configuration screen. Just enter template names along with the image field you wish to use: basic-page,image Or basic-page,image.landscape document1,image.portrait 4. It now supports also FieldtypeCropImage (v1) FieldtypeCroppableImage (v2) FieldtypeCroppableImage3 (v3) ... Thanks @adrian for the patience to fix some old problem, and give a hint at new PW3 menu issue. Strange looking at it after years6 points
-
This week, some more layout options have been added to it that I think many may find useful. This post highlights them with a screencast: https://processwire.com/blog/posts/processwire-3.0.57-and-admin-theme-framework-updates/4 points
-
2 points
-
Great thing @Robin S! Something to make content creation even easier. I see there is an option to exclude some Hanna codes from the list. What do you think about a whitelist option (preferably overridden on a template basis)?2 points
-
I've modified the editlink macro in v039, now you can easily add any attributes and additional url parameters to the edit link. This way it's easy to add edit links that open the admin in a lightbox. I've added a few lines about it to the docs along with a style example.2 points
-
It is not when the property has empty values, it is when there isn't a key available. Your request return multidimensional array. If there is, for what ever reason, not set a key 'Make' or 'Model' for example, PHP will throw a notice when you simply try to use $myArray['availableKey']['notAvailableKey']. So, if you are 100% sure that all images that you ever will use with that code will have all requested EXIF-fields, let out the validation.2 points
-
it's a really amazing module, and will be indispensable for any site using hanna codes, i can already see this solving major problems with users entering incorrect stuff into their hanna codes. the options and description stuff is also amazing work!1 point
-
it's working well so far... the only error i encountered was because the hanna code module config may not even be populated if you install hanna code and use the defaults, and never actually save the module, so one option would be to also check if the index for that module config is set, (around like 150 of the module)...1 point
-
In v0.0.2 I have added a hookable method that supplies the array of tag names for the dropdown menu. You can use an 'after' hook to control what appears in the dropdown. A couple of examples... Define the tags for a given template: $this->addHookAfter('HannaCodeDialog::getDropdownTags', function($event) { $page = $event->arguments('page'); // Show only these tags on pages using the 'basic_page' template if($page->template == 'basic_page') { $event->return = ['some_tag', 'another_tag']; } }); Remove certain tags for a given template: $this->addHookAfter('HannaCodeDialog::getDropdownTags', function($event) { $page = $event->arguments('page'); $tags = $event->return; // Remove these tags on pages using the 'basic_page' template if($page->template == 'basic_page') { $filtered_tags = array_filter($tags, function($tag) { return !in_array($tag, ['some_tag', 'another_tag']); }); $event->return = array_values($filtered_tags); } });1 point
-
Could you try and shorten the fromName and toName (or replace it with plain ascii ones) for testing and see if that fixes it? It might be a line wrapping issue in one of those two.1 point
-
Is the first line complete? The missing from: header start and quoted-printable preamble is the only thing I see that's incorrect. If it's not, can you make sure that there are no line breaks in the fromName? setLocale shouldn't have any influence on WireMail's behavior.1 point
-
1 point
-
You can get language value for each language field by using $page->getLanguageValue(language, field); foreach($languages as $language) echo $language->name, " : " , $page->getLanguageValue($language, 'title') , "<br/>"1 point
-
Hi ! Please welcome https://www.docpaddock.com/en/ It's a brand new rebuild of an old project called Trajectons.com (not online any more). It's a competition of predictions. You have to guess some podiums in MotoGP/Moto2/Moto3 categories or F1 (I'm a MotoGP fan). You have a free plan, another one where you can buy an avatar generator, and a Pro one to unlock some cool features. I knew nothing about PW a few months ago and its community helped me a *lot*. I wouldn't have be able to do this without your help. So thank you and have a look if you're into that kind of sports competition You can still sign up before the first Grands Prix seasons : it starts this sunday (26/03).1 point
-
hi @Zeka, Thanks for your feedback ! I know there is some tuning to do, at the moment I'm preparing the backend stuff for the sunday races. I'm alone on this project and can't deal with everything on the same day but I'll improve the website day after day. favicon, minify are now planned, thx1 point
-
1 point
-
I don't think there is a setting or hookable method you can use for this. But AdminOnSteroids adds body classes based on the user role, so you could use a bit of custom jQuery to remove the Tree panel toggle button for a role: // remove Tree panel toggle for editor role $('body.role-editor').find('.pw-panel[data-tab-icon="sitemap"]').parent('li').remove();1 point
-
@Cengiz Deniz Yep, it works very well, but only until you request a key that is not available in an image, than it will throw notices or warnings. The new module I linked to, lets you do the exact same as you does, but without the redundant hassle of validation. So, you can use your code, but I suggest to add a check for available keys: $image="http://cdeniz.com/".$img->url; $exif = exif_read_data($image, NULL, true, true); $tarih = isset($exif["EXIF"]["DateTimeOriginal"]) ? $exif["EXIF"]["DateTimeOriginal"] : 'N/A'; // or anything you want, like '', null, ... $kamera= (isset($exif["IFD0"]["Make"]) ? $exif["IFD0"]["Make"] : '') . " " . (isset($exif["IFD0"]["Model"]) ? $exif["IFD0"]["Model"] : ''); ... ... ... Personally I find this to unreadable and redundant, therefore I prefer the new modules way: $options = array('keys' => array('DateTimeOriginal', 'Make', 'Model'), 'toObject' => true); $exif = $image->getExif($options); // now I can access like this: $tarih = $exif->DateTimeOriginal; $kamera = $exif->Make . ' ' . $exif->Model;1 point
-
Also: https://processwire.com/blog/posts/introducing-a-new-processwire-site-profile/1 point
-
Welcome back NooseLadder. Is it already a year ago ? Time really flies man. I remember your posts very well. Here you go: https://github.com/ryancramerdesign/BlogProfile http://modules.processwire.com/modules/process-blog/ Remembering your posts I think you have enough code experience for using pw.1 point
-
1 point
-
You form looks like $sanitizer->option() and ->options() should be enough. There's no input where a user is supposed to supply other values than the ones you supply.1 point
-
Two new macros in v038: minify and editlink. Minify is an easy way to remove unnecessary whitespace and optionally to try some additional tweaks too. It's nowhere to ProCache or AIOM but can help reducing markup size. I could tweak things on one site to achieve 100% HTML minification according to gtmetrix but that required extra work on the markup so this macro alone won't help you on this As a bonus the macro can be used to remove whitespace between list items (<li>'s) which sometimes can cause headaches. Editlink is another helper that can substitute bigger modules like FEEL, Fredi or the built-in frontend editor. There's nothing special in it, just outputs edit links to edit the page in the admin. First I was about to modify FEEL but I realized this would be more fun1 point
-
1 point
-
@gmclelland - latest version includes node_modules and sass-cache as default directories to exclude. On an unrelated note, I have also added a new "Selector Queries" section to the PW Debug panel. This shows you all the selector calls made during the current page load. This post also includes a Console Panel snippet idea. If you need to look up a page, template or field ID, this snippet will return the name, title, label, edit and view links, etc. Just enter the ID and the type and run. I have saved it as "Info from ID", but you can choose whatever name you want. Code included in a spoiler below.1 point
-
just because i needed this again today: if you are dealing with any sort of tags (HTML data) in your fields, than the easiest solution is to base64_encode($var) your data in the export and then base64_decode($var) it in your import. i had to import some pages with inline images today and if you know how to do it, that is also quite easy and straigtforward. the problem is, that you have some html like img src="/site/assets/files/12345/your-image.jpg" in your field and the ID will change after the import! sample export xml - note the tag <pid> holding the old id echo "<?xml version='1.0' ?>"; echo '<pages>'; // find pages $results = $pages->find('parent=/your-parent/'); $results->add($pages->find('parent=/something-else/')); foreach($results as $p): $p->of(false); ?> <page> <title><?= $p->get('headline|title') ?></title> <date><?= $p->created ?></date> <featured>1</featured> <pid><?= $p->id ?></pid> <pic><?= $p->coverpic->first()->httpUrl ?: '' ?></pic> <body><?= base64_encode($p->body) ?></body> <images><?php foreach($p->images as $image) { echo '<image>' . $image->httpUrl . '</image>'; } ?></images> <files><?php foreach($p->attachments as $file) { echo '<file>' . $file->httpUrl . '</file>'; } ?></files> <gallery><?php foreach($p->gallery as $image) { echo '<image>' . $image->httpUrl . '</image>'; } ?></gallery> </page> <?php endforeach; echo '</pages>'; die(); and then the import: $items = simplexml_load_file('your-url-of-export-data'); foreach($items as $page) { $p = new Page(); $p->template = 'blogitem'; $p->parent = '/news'; $p->title = $page->title; $p->name = $sanitizer->pageName($page->title, true); while($pages->find('parent='.$p->parent.',name='.$p->name)->count() > 0) $p->name .= '-'; $p->date = $page->date; $p->featured = $page->featured; // get body html and remove root node $p->body = base64_decode($page->body); $p->save(); // change images in body field $re = '/src="\/site\/assets\/files\/' . $page->pid . '\//'; $p->body = preg_replace($re, 'src="/site/assets/files/' . $p->id . '/', $p->body); $p->save(); // add images if(strlen($page->pic)) $p->pic->add((string)$page->pic); foreach($page->images->image as $image) $p->images->add((string)$image); foreach($page->files->file as $file) $p->files->add((string)$file); foreach($page->gallery->image as $image) $p->gallery->add((string)$image); $p->save(); echo 'new page <a href="' . $p->editUrl . '" target="_blank">' . $p->path . '</a><br>'; } die(); just set your ckeditor field settings porperly before your import and all images will be recreated on your new site! remark: this will only replace images from the same page and not any images that are linked from a different page with different page-id. that would need some extra mapping of old-id --> new-id1 point
-
You can do it in the module. Here is the code of an module which changes the path names for multilingual site. <?php /** * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class CorrectPagenames extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'CorrectPagenames', 'version' => 1, 'summary' => 'Output custom path names multilingual', 'singular' => true, // Limit the module to a single instance 'autoload' => true // Load the module with every call to ProcessWire ); } public function init() { // init() is called when the module is loaded. // saveReady is a hook after processing the previous changes of the page, // but just before those changes are saved to the database. // It's called for each page that's being saved, no matter if it's in // the backend or in your templates via the api. $this->addHookBefore('Pages::saveReady', $this, 'beforeSaveReady'); } public function beforeSaveReady($event) { $page = $event->arguments[0]; //create custom path name for children events $datestart = $page->publish_from; // I use the publish from date for the path name $datestart = date('Y-m-d', $datestart); $eventtitle = $page->parent->title; // I also use the parent title for the path name $page->name = $eventtitle . '-' . $datestart; //putting it all together for the default language foreach ($this->languages as $lang) { //multilanguage starts here if ($lang->isDefault()) continue; $lname = $lang->id; $pageName = $page->title->getLanguageValue($lang); $pageName = $pageName . '-' . $datestart;// create custom path for other languages $pagelanguage = "name" . $lang; $page->$pagelanguage = $pageName; //this sets the path name for each language } } } You can take a look on how to achive it (as an inspiration ) Best regards1 point
-
yes, we can help! you just need to add check_access=0 to your selector http://cheatsheet.processwire.com/selectors/built-in-page-selector-properties/check_access-0/1 point
-
Thanks Martijn and Soma for your replies! 3 great approaches from you both. That's awesome. I never thought of moving out a core module to our sites folder and modifying it. But I feel most comfortable with that approach and I'm happy going with that. Thanks for that link Soma. It contains a very instructional concept of great value. Nontheless.... I still think it would be of great value for the comment form API to be able to accept a class for the submit button without using any of our workarounds! We can currently configure just about everything else that is needed via the API, so why not the submit class as well? I'm very certain more people in the future who want to style the button would be looking for it expecting to find it in the API Anyway... it was just a wish Cheers guys!1 point