Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/24/2016 in all areas

  1. LimitRepeater Allows restrictions and limits to be placed on Repeater fields. For any Repeater field you can limit the number of items that may be added and also prevent the use of drag-sorting, toggling of published state, and the trashing of items. There is also an option to hide the clone button when the limit is reached. Usage Install the LimitRepeater module. Since v0.2.0 the module settings are configured at Setup > Fields > [your Repeater field]. The settings are contained within the "Restrictions" fieldset on the "Details" tab. Please note that the restrictions limits are applied in Page Edit with CSS/JS so should not be considered tamper-proof. Setting restrictions via a hook Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking LimitRepeater::checkRestrictions. This allows for more focused restrictions, for example, applying restrictions depending on the template of the page being edited or depending on the role of the user. The checkRestrictions() method receives the following arguments: $field This Repeater field $inputfield This Repeater inputfield $page The page that is open in ProcessPageEdit The method returns an array of restrictions for the Repeater field. An example of a returned array: Example hook Prevent non-superusers from trashing any items in "my_repeater_field": $wire->addHookAfter('LimitRepeater::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $restrictions = $event->return; if($field->name === 'my_repeater_field' && !$this->user->isSuperuser()) { $restrictions['notrash'] = true; } $event->return = $restrictions; }); Upgrading from < v0.2.0 There are two major changes to be aware of when upgrading from earlier versions of the module. The settings are no longer defined on the module config page, but rather in the field settings of each Repeater field: Setup > Fields > [your Repeater field]. If you visit the module config page you'll find shortcuts to the settings for each Repeater field. In earlier versions you could apply restrictions to a particular role. This is still possible but is now handled by hooking LimitRepeater::checkRestrictions as this is a more flexible and powerful approach. If you were applying restrictions to a particular role or roles you'll need to add hook code to achieve the same effect after you upgrade the module. See the hook information above in this readme. https://github.com/Toutouwai/LimitRepeater http://modules.processwire.com/modules/limit-repeater/
    8 points
  2. For modules not in the modules directory and not on Github I always update by doing: Modules > Site > Add New > Add Modules From Upload That will also update an existing module. To me that is easier than unzipping and replacing folder.
    3 points
  3. You can disable multi language for the entire template, not per field (on the Advanced tab as I remember).
    3 points
  4. @Robin S you're a man of no limits these days! Btw, what is that text from
    3 points
  5. @MaryMatlow I believe this is an active community here... Let make it lot clear for you. Here what you did... <?php $nav = $modules->get("MarkupSimpleNavigation"); $nav_options = array( 'list_tpl' => '<li class="dropdown">||</li>' ); echo $nav->render($nav_options); ?> The result... <nav> <ul> <li class="dropdown">...</li> <li class="dropdown">...</li> <li class="dropdown">...</li> /*has children*/ <ul> <li class="dropdown">...</li> <li class="dropdown">...</li> <li class="dropdown">...</li> <li class="dropdown">...</li> </ul> <li class="dropdown">...</li> </ul> </nav> Entire <li> is getting class called dropdown, even it will override <li> default class. Now if you change this... <?php $nav = $modules->get("MarkupSimpleNavigation"); $nav_options = array( 'has_children_class' => 'has_children dropdown', ); echo $nav->render($nav_options); ?> The result will show <li> with children contain two classes "has_children" and "dropdown" just like @Robin S showed you. <nav> <ul> <li>...</li> <li>...</li> <li class="has_children dropdown">...</li> /*has children*/ <ul> <li>...</li> <li>...</li> <li>...</li> <li>...</li> </ul> <li>...</li> </ul> </nav> You can as well use only one class name "dropdown" this.. <?php $nav = $modules->get("MarkupSimpleNavigation"); $nav_options = array( 'has_children_class' => 'dropdown', ); echo $nav->render($nav_options); ?> and it will assign <li> with only class name "dropdown" as result... <nav> <ul> <li>...</li> <li>...</li> <li class="dropdown">...</li> /*has children*/ <ul> <li>...</li> <li>...</li> <li>...</li> <li>...</li> </ul> <li>...</li> </ul> or leave blank.... <?php $nav = $modules->get("MarkupSimpleNavigation"); ?> the result still will show <li> with children with default class "has_children" since MSN detects existing children <ul> <li>...</li> <li>...</li> <li class="has_children">...</li> /*has children*/ <ul> <li>...</li> <li>...</li> <li>...</li> <li>...</li> </ul> <li>...</li> </ul> Hope this one really helps.
    3 points
  6. Media Manager version 007 (released (23/11/2016)) Happy to announce the latest release of Media Manager. Download via your purchase link. Changelog Multi-tagging: Added to the list of actions to apply to selected media. Tick the checkbox to replace rather than append to existing tags. 'Un-tagging' also available in the list of actions. Uploading now possible when in CKEditor context. Settings moved to own menu item. New settings added: Media title format; Handling duplicate media (all 4 media types); Display current users' media only; Media sorting + sort order Replace/Rename/Skip Duplicate media: When new media loaded and a duplicate is found in the library, this setting tells MM what to do. If using 'Replace' mode, existing tags and descriptions are preserved. There is also a setting to preserve or delete existing image media variations. @note: Might need a couple of refreshes (browser and/or MM before replacement media is shown). Media Sorting: Set via settings (@see #4). Live Media Sorting: In your Media Manager Library, select sort criteria (dropdown select) and sort order (checkbox). These override the sort settings in 'Settings' (@see #3). List and Grid View: Click on respective icons to switch to list versus grid view. In list-view, the current media (displayed on the right pane) remains in view as you scroll the page. @note: currently there is a bug where your media image will remain fixed at the top of the window when you scroll back up in cases where it is taller than your monitor. Please see this post. Insert Link and Insert Image: Streamlined insert link and insert image in CKEditor. MMLink and MMImage plugins are now obsolete! Go ahead and delete them please. Instead, we use and extend ProcessWire's inbuilt PWImage and PWLink. Code refactoring, bug fixes, CSS fixes. @note: As previously announced, this version is still not yet certified as compatible with ProcessWire 2.8 and 3.X. This means the repeater matrix bugs will still be present. Next version of MM will be compatible with these versions of PW.
    3 points
  7. You can use $this->animal $this->animal = 'cat'; $this->addHookAfter('Page::render', function($event) { bd($this->animal); }); or you can also do this: $animal = 'cat'; $this->addHookAfter('Page::render', function($event) use($animal) { bd($animal); });
    2 points
  8. @horst, I thought I'd share my implementation of an auto-watermarking module. This module depends on PIM, and also depends on some other stuff specific to the application the module was created for. If anybody wants to use this module for their own uses, you'll have to change the names of fields and templates that you want to apply a watermark to. We (PROGRESS: A Creative Agency) do plan to modify this module for more general use in future, and release it in the module directory. But we are really busy right now, and cannot do so. See the GitHub gist here.
    2 points
  9. @MaryMatlow, the commented default options in the MarkupSimpleNavigation docs say this... 'list_tpl' => '<li%s>||</li>', // template string for the items. || will contain entries, %s will replaced with class="..." string %s is a placeholder for the dynamic classes such as 'has_children', 'level-n', etc. If you remove the %s placeholder in list_tpl as you have done in your options there is nowhere for the dynamic classes to be inserted. So revert back to the default for list_tpl (and as @Speed said, you only need to set options you are changing from the default). If you want 'dropdown' to be added to the classes of every list item you set this... 'list_field_class' => 'dropdown', ...or if you want it to be added to the classes of only list items that have children you set this... 'has_children_class' => 'has_children dropdown',
    2 points
  10. As a web developer I always want to improve the search results of my websites in popular search engines. Because of that I find the topic of structured data very interesting and want to learn more about them. Recently I tried out a few of the ways how to provide more information to a website and want to share my solutions. Most of the structured data can be included directly in the markup or as JSON-LD at the end of your document (right before the closing body tag). I prefer the last one, because I don't like to have bloated HTML markup. Breadcrumbs Breadcrumbs are an alternative way to show the your page hierarchy inside search results, instead of showing just the plain URL. Just like the breadcrumbs on a website. Following the example, I ended up with this code: <?php if(strlen($page->parents()) > 0) { ?> <!-- Breadcrumbs --> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [ <?php $positionCounter = 1; $separator = ','; foreach($page->parents() as $parent) { if($parent->id == $page->parents()->last()->id) { $separator = ''; } echo ' { "@type": "ListItem", "position": "' . $positionCounter . '", "item": { "@id": "' . $parent->httpUrl . '", "name": "' . $parent->title . '" } }' . $separator . ' '; $positionCounter++; } ?> ] } </script> <?php } ?> First I am checking if the page has parents, then I follow the follow the markup of the example. I save the position of each parent in the variable positionCounter and increase its amount after each loop. As a last step I tried to end the JSON objects by not include the separating comma after the last object. This is why I am using the separator variable. Site name and sitelinks searchbox Using JSON-LD you can provide an alternative site name and a sitelinks searchbox inside the search results (Inception ). <!-- WebSite --> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "WebSite", "name" : "Your site name", "alternateName" : "Your alternative site name", "url": "<?= $pages->get(1)->httpUrl ?>", "potentialAction": { "@type": "SearchAction", "target": "<?= $pages->get(1)->httpUrl ?>search/?q={search_term_string}", "query-input": "required name=search_term_string" } } </script> I am not 100% sure, if the sitelinks searchbox works this way. Maybe someone who made this work before could confirm it, that would help me out. Organization For organizations you could provide a logo and links to your social profiles. <!-- Organization --> <script type="application/ld+json"> { "@context": "http://schema.org", "@type" : "Organization", "name" : "Your organization name", "url" : "<?= $pages->get(1)->httpUrl ?>", "logo": "<?= $pages->get(1)->httpUrl ?>site/templates/images/logo.png", "sameAs" : [ "https://www.facebook.com/your-organization-url", "https://www.instagram.com/your-organization-url/" // All your social profiles ] } </script> This one I think is self explanatory. Article If you have an blog or a news site you could enhance your articles with structured data with an thumbnail and author. <?php if($page->template == "post") { ?> <!-- Article --> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "NewsArticle", "mainEntityOfPage": { "@type": "WebPage", "@id": "<?= $page->httpUrl ?>" }, "headline": "<?= $page->title ?>", "image": { "@type": "ImageObject", "url": "<?= $page->thumbnail->httpUrl ?>", // Image field in template "height": <?= $page->thumbnail->height ?>, "width": <?= $page->thumbnail->width ?> }, "datePublished": "<?= date('c', $page->created) ?>", "dateModified": "<?= date('c', $page->modified) ?>", "author": { "@type": "Person", "name": "<?= $page->createdUser->first_name . ' ' . $page->createdUser->last_name ?>" // Text fields added to core module ProcessProfile }, "publisher": { "@type": "Organization", "name": "Your organization name", "logo": { "@type": "ImageObject", "url": "<?= $pages->get(1)->httpUrl ?>site/templates/images/logo.png", "width": 244, // Width of your logo "height": 36 // Height of your logo } }, "description": "<?= $page->summary ?>" // Text field in template } </script> <?php } ?> Here I am enabling structured data for the template called post. I also have the text fields first_name and last_name added to the core module ProcessProfile, the image field thumbnail and the text field summary added to the template. Just a small note: I know you could use $config->httpHost instead of $pages->get(1)->httpUrl, but I found the second one more flexibel for changing environments where you have for example HTTPS enabled. Those are the structured data I have in use so far. I hope I haven't made a mistake, at least the testing tool doesn't complain. But if you find something, please let me know. I love how easy it is with ProcessWire to get all the information from various pages and use them in this context. As mentioned above, I am nowhere an expert with structured data, but maybe some of you would like to provide also some examples in this thread. Regards, Andreas
    1 point
  11. This module helps you dynamically create schemas for improved SEO & SERP listings from within your templates. Each schema can be configured to meet your requirements. You can even add your own ProcessWire schema classes to the module. Read about the module on github: https://github.com/clipmagic/MarkupJsonLDSchema Download from github: https://github.com/clipmagic/MarkupJsonLDSchema/zipball/master Download from ProcessWire modules: http://modules.processwire.com/modules/markup-json-ldschema/
    1 point
  12. You will find debugging much easier using Tracy Debugger than with $this->message. Have you seen these modules and topics relating to Amazon storage? http://modules.processwire.com/modules/amazon-s3-cloudfront/ http://modules.processwire.com/modules/schedule-cloud-backups/
    1 point
  13. Thanks @adrian, I knew there would be a simple solution. And, thanks @kongondo
    1 point
  14. $animal = 'cat'; $this->addHookAfter('Class::method', function($event) use($animal) { // is there some way to use $animal here? Yes....use 'use' echo $animal; }); Edit...OK, so I am too slow....
    1 point
  15. Thanks for your help @adrian it is working now! Solution: (function ($) { $( document ).ready(function() { $('#Inputfield_city').on( 'blur', function() { var address = $('#Inputfield_street').val() + ', ' + $('#Inputfield_city').val(); $('#Inputfield_location').val(address); $('#Inputfield_location').blur(); }); }); }(jQuery));
    1 point
  16. If everything works with that JS entered into your browser dev tools console, and the basic-page.js is loaded, then it's likely that the script is being called before the page's input fields are ready. Try wrapping it so it looks like this: (function ($) { $('#Inputfield_city').on( "blur", function() { var address = $('#Inputfield_street').val() + ', ' + $('#Inputfield_city').val(); $('#Inputfield_location').val(address); $('#Inputfield_location').blur(); }); }(jQuery));
    1 point
  17. Wow, thanks! Good to see active and responsive development! Though, unfortunately, I had avoided the need to get the variations. At least the next guy won't have an issue! Yes, I'm secretly spying on everything you do! I knew!
    1 point
  18. Holy ghost, @CaelanStewart, it feeled that you have liked my post just before I had posted it!?!
    1 point
  19. @CaelanStewart: I have added it, but changed the default! So, everytime now you get a refreshed version. I think that way round it is more like the common expectations. Only if one have a more advanced usecase, he may be aware of the switch and has a need for it. https://github.com/horst-n/PageImageManipulator/commit/ef8a6af6acc49e31d39fa63d6faa696428e30f83
    1 point
  20. It would be simple to make it only grab the first page: https://github.com/adrianbj/ProcessPDFImageCreator/blob/12a402175c39b506d49497d201f79bd8db6313ef/ProcessPDFImageCreator.module#L138-L140 Replace with: $this->createPdfImage($page, $image_field, $pdf_field_name, 0); I don't know if it will work in a repeater - I haven't tested, but I expect it will need some tweaks to reference the actual page correctly.
    1 point
  21. If you ever have this situation again, it's fairly easy to delete a module via the database. Deleting a field is also possible although there are some more things to consider. I just took a look at that module and it definitely will need some tweaking to get working with PW 3 because of it's use of namespaces and the way extends just certain fieldtype classes in PW, rather than Wire or WireData. I do know for certain that my old module (linked to above) works on PW 3 - I am using it on several sites. It is definitely less polished, but it gets the job done
    1 point
  22. 1 point
  23. Checked again and it works fine on FF and Chrome in Windows. Wondering if it's a Mac thing? Are you able to test on a Mac machine? Anyone else experiencing this? Edit: Facepalm! I should have noted your image dimensions. I forgot to add that to the release notes. For tall images (yours is 2000px high) you will (currently) experience that problem. It has to do with the JS calculating how far the window has been scrolled up in relation to the height of your monitor minus the height of the parent div of the preview/edit panel (the difference). If your image is taller than your monitor, that will result in a negative difference and hence when you scroll back up, the 'fixed' class is not removed. I wasn't able to find a solution before this release but will work on it. Apologies.
    1 point
  24. @Nukro, Update is same as any other ProcessWire module. However, in this case, we also have to delete the following folders: /site/modules/InputfieldCKEditor/plugins/mmimage/ /site/modules/InputfieldCKEditor/plugins/mmlink/ /site/modules/MediaManager/plugins/ In addition, you need to remove references to the the plugins MMImage and MMLink from any CKEditor field that were using them. Edit the field Go to Input Tab Under CKEditor Settings > CKEditor Toolbar delete references to MMImage and MMLink Scroll down to Plugins and untick mmimage and mmlink Save The update does not write anything; neither to your file system nor to your database. Therefore, it shouldn't affect anything related or unrelated. Better to be safe always, however, so, create a backup of your site first Backup your files and db replace or overwrite the contents of /site/modules/MediaManager/ with the contents of the folder MediaManager-007. If overwriting, remember to delete the plugins folders as stated above since there will be nothing to overwrite them with from the MediaManager-007 folder Hit module refresh Test that everything works fine Acquaint yourself with the latest changes Let your clients know about the changes
    1 point
  25. @horst, hi there. I wrote the code I posted specifically for this thread - the prefix is present in the actual code. Perhaps you could add an option to disable the caching of variations, or perhaps add a parameter to the getPimVariations() method that ignores the cache, like so? $pim = $page->image->pim2Load('some-prefix'); $pim->getPimVariations(true); // Passing true skips the cache
    1 point
  26. It depends on what you are referring to. If you are referring to what is actually stored in the db, then you are right, but if you are talking about what is being sent to the server, than your statement it is not quite true, since hacking is all about changing the latter. On the other hand, I agree that in the case of checkboxes it is more about validation than sanitization, just like explained in the comments of the accepted answer here: http://stackoverflow.com/questions/26327953/sanitize-a-value-from-select-radio-checkbox
    1 point
  27. Thanks for that @tpr - I hadn't really noticed that option since I started doing multi-language sites just recently. The nice thing about that is that you can set that $page->template->noLang = 1; at runtime which means you can add some logic in your site ready.php file to determine which pages have multi-language fields enabled/disabled. Here is a quick idea that disables all multi-language fields on the branch that with the parent of ID: 1111 $p = $pages->get((int)$input->get->id); if($p->parents("id=1111")->count()>0 || $p->id === 1111) { $p->template->noLang = 1; } Now what I would actually like to do is control which languages are available in on a per branch basis - so I have this request in: https://github.com/processwire/processwire-requests/issues/54 and also here are my initial ideas around this:
    1 point
  28. When you're editing a page and meanwhile your login session expires, there should be a warning. I don't know why, but I found myself in that situation at least twice and a friend of mine had lost text (got an email just now) . Maybe if the connection has dropped while you write or some other timeout!? Anyhow, if you click save you are forwarded to the login page and the content is lost. Quite harmful Perhaps the "Save" button could check if the session is still available before finally submitting. Or a warning at the top and bottom. I think WordPress made a good solution and opens a modal window if you're session is lost.
    1 point
  29. Is this what you are looking for: foreach ($categ_team as $categ) { $content .= "<h2><a href='{$categ->url}'>{$categ->title}</a></h2>"; //MSc, stagiaire $years = $page->find("template=member, featured=0, categ_team=$categ"); foreach ($years as $y){ if($y !== $currentYear) $content .= "<h3>{$y->date_begin}</h3>";//les années $member = $page->find("template=member, featured=0, date_begin={$y->date_begin}, categ_team=$categ"); foreach($member as $m) { $content .= "<h4><a href='{$m->url}'>{$m->title}</a></h4>"; //nom de l'étudiant } $currentYear = $y; } }
    1 point
  30. @Wanze I kinda assumed that using 3 was part of it. I'll look forward to the update. Thank you for your reply.
    1 point
  31. Another, maybe better, approach would be to use AdminCustomFiles (http://modules.processwire.com/modules/admin-custom-files/) to add some custom JS to do this on-the-fly. Then use jQuery to grab the contents of your street and city fields, concatenate them, insert them into the map address field and then blur so that google maps triggers a geocode. Maybe something like this: $('#Inputfield_city').on( "blur", function() { var address = $('#Inputfield_street_address').val() + ' ' + $('#Inputfield_city').val(); $('#Inputfield_map').val(address); $('#Inputfield_map').blur(); }); On limited testing here it seems to work just fine. Of course it assumes the address field is named "street_address" and the city field is "city" and the mapmarker field is simply "map". Let me know if that works for you. Don't forget that you can test via your dev console so you know it's working before adding via Admin Custom Files. PS - of course you can always add commas, and even state and country elements to the address that goes into the map address field for geocoding.
    1 point
  32. I'm really enjoying module development in PW. The flexibility that comes from hooks is brilliant. A couple more modules due shortly. An all-time classic.
    1 point
  33. I see your problem, this array string below... 'list_tpl' => '<li class="dropdown">||</li>' Overrides has_children class as default. And this string will add 'dropdown' class to whole element that has <li>. Use this string... 'has_children_class' => 'has_children', If you only want to change <li> classname that have children only. BTW, you don't really need to input entire stack of arrays since the list are already default, only randomly pick one that need to override it's defaults. Hope that helps
    1 point
  34. I have always been a huge fan of the vector shape side of SVG, but I have never really experimented with all its other abilities. Here's an interesting article on some of the other things it can do: http://go.sitepoint.com/t/ViewEmail/y/28B66532868053D2/93084645AE7B31BD981D23A7722F2DCD Just pinging @horst because it may be of particular interest to him
    1 point
  35. I had a similar problem to this when I wrote a module for a client. It turned out that having a tab open on the module's log page stopped the hook from firing, even though I had a cron job, running every minute, visiting a page on the site. As far as I can tell, the auto refresh that occurs on the log pages somehow stops the hook from triggering. Once I closed the log view page, I could watch things go back to normal just be looking at the actual log file from the command line using the 'tail -f' command. The solution for me was to only open the log pages when needed and provide my own view of the log tail as part of the module's settings page. HTH
    1 point
  36. Oh, yes you're correct. According to the reference, addresses are associated with Organization, not localBusiness. I will fix and update the module. https://developers.google.com/schemas/reference/types/Place https://developers.google.com/schemas/reference/types/LocalBusiness Thanks for bringing this to my attention.
    1 point
  37. oops sorry meant this https://search.google.com/structured-data/testing-tool to see the json i usually dump it to tracy debugger
    1 point
  38. Just spent the last couple of hours trying to work out why the input dates wouldn't work for non English months until I found this post. Would be helpful to have a warning note as suggested in Date Input Format for others that come across this issue.
    1 point
  39. Yep the Datepicker does the translation, and it seems converting it back does fail. In master version 2.2.9 there's no translation happening from the Datepicker, so you're right. Certain formats like "Y-M-j, l" work but get translated back to english when saved which is wierd. I guess the best would be to have the input digit based as you say. I can live with that. Thanks
    1 point
×
×
  • Create New...