Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/31/2022 in all areas

  1. This week we have ProcessWire 3.0.201 on the dev branch which includes a couple minor fixes but also a couple of useful additions: There are new "Tab" field visibility options available for any field in the page editor. This makes the field display in its own page editor tab. It saves you from having to create a new/separate Tab field just to wrap around an existing field to make it display in a tab. So far I've found it particularly useful with ProFields (Combo, Table, Textareas, RepeaterMatrix) as well as the core Repeater, FieldsetPage and Images fields. For instance, I have a Combo field labeled "SEO" that lets me edit browser_title, meta_description, canonical_url, etc., and now I can add that field to any template and pages using that template have their own "SEO" tab. Sure you could do this before by creating a separate tab field with an "SEO" label, but now it's a lot simpler/faster, as any field can now display as a tab on its own. Like with the other visibility modes, also included are options to make the tab load dynamically on click with ajax or make the value non-editable. You can also optionally specify a label for the tab independently of the field label. This is because usually you want tab labels to be very short (1 word is best) whereas field labels have no such need. Please note that this new Tab option is exclusive to the page editor, and in order to work the field must not already be in a tab. Also added this week is a new $page->getMultiple() method. This method works the same as the $page->get() method except that it lets you retrieve multiple page property/field values at once and returns them in an array. For example: $a = $page->getMultiple([ 'foo', 'bar', 'baz' ]); list($foo, $bar, $baz) = $a; It also accepts a CSV string: $a = $page->getMultiple('foo,bar,baz'); By default it returns a regular PHP array, suitable for using in list() like the first example. But if you want it to return an associative array instead, then specify true as the 2nd argument: $a = $page->getMultiple('foo,bar,baz', true); echo $a['foo']; echo $a['bar']; echo $a['baz']; I find this method useful in reducing the amount of code/lines necessary in many cases, and most often I use it in combination with a PHP list() call, i.e. list($title,$subtitle,$body) = $page->getMultiple('title,subtitle,body'); That's all for this week. Thanks for reading and have a great weekend!
    2 points
  2. This could be a job for the Elvis operator: //if $page->prev-path is empty, get the path of the parent's last child (sorted by sort descending), i.e. loop around to the end echo "<a href='" . ($page->prev->path ?: $page->parent->child('sort=-sort')->path) . "'><i class='fas fa-arrow-left'></i></a>"; //if $page->next-path is empty, get the path of the parent's first child, i.e. flip over to the beginning echo "<a href='" . ($page->next->path ?: $page->parent->child->path) . "'><i class='fas fa-arrow-right'></i></a>"; Btw in your if-condition you're checking for the next and previous sibling of a specific template, but you output the next/previous sibling without this restriction, so if you have mixed templates in this branch of your page tree, you may get unexpected results. I've left out the template conditions in my snippet above, you may want to add them in the appropriate places.
    2 points
  3. Admin Theme Canvas A minimal admin theme with optimised page editor UI, based on Uikit 3. Currently this is close to stable, but users are advised to be cautious and test thoroughly. This theme is tested in all major Browsers including IE 11, Edge (>85), Chrome (>85), Firefox (>81), Safari (>11). If you find any bugs or have ideas for improvements, feel free to post your feedback. Download from Github Download from Modules Page Features Minimal black and white admin theme Fixed masthead navigation Direct access to page tree navigation inside page dropdown Less distraction for editors (when editing a page, the tabs are displayed as a dropdown menu inside the main navigation) Options to customise the ui Less distraction for editors Direct access to page tree navigation inside dropdown Page tree Options to customise the ui Login (inspired by AdminThemeBoss) Requirements Process Wire 3.0.100 or greater Installation Go to “Modules > Site > Add New“ Paste the Module Class Name “AdminThemeCanvas“ into the field “Add Module From Directory“ Click “Download And Install“ On the overview, click “Download And Install“ again… On the following screen, click “Install Now“ Go to your user profile page and change the theme to Admin Theme Canvas
    1 point
  4. Thanks everyone. This works great. I thought I'd have to make something much more complex. <?php echo "<a href='" . ($page->prev("template=staff-detail")->path ?: $page->siblings("template=staff-detail")->last->path)."'><i class='fas fa-arrow-left'></i></a>"; echo "<a href='" . ($page->next("template=staff-detail")->path ?: $page->siblings("template=staff-detail")->first->path) . "'><i class='fas fa-arrow-right'></i></a>"; ?> The colon in the two echo statements seems to be some kind of shorthand for if/else. I hadn't seen it before so thanks for the tip. ?
    1 point
  5. Great solution ? Imho $page->siblings()->last() and $page->siblings()->first() would be a little bit easier to read ?
    1 point
  6. I've just tried the theme with a different website, and the issue isn't there. So it must be something unique to this site, and not the theme.
    1 point
  7. Thanks elabx! I read the documentation a bit too quickly ? For anyone having the same misunderstanding in the future, I solved it by using PHP array_search().
    1 point
  8. I don't think there is any module that does exactly what you're asking about, but I expect it wouldn't be that hard to achieve without needing any module. We probably need to hear a longer explanation of what you're wanting to do. If the pages of the "book" can be grouped together in the tree in the form... Book title - Chapter ...or... Book title - Chapter -- Subsection --- etc ...then you can create your navigation links using $page->children(), $page->next(), $page->prev() etc. Or if the pages are scattered throughout the site but need to be grouped together for use in a book then you can use a Page Reference field to select all the pages that make up the book. As the book is browsed you can keep track of the fact the visitor is viewing the pages as a book by passing a URL parameter on each navigation link like ?book=my-book-title and this will let you work out the previous and next pages for use in the navigation. If you want to divide the long text into multiple pages on save then you can use a Pages::saveReady hook to parse the HTML and find the tags that you want to split on, then create new pages with the split content using the API. Or if you want to keep the long text in one piece but paginate it on the front-end then you could take a look at TextformatterPagination.
    1 point
  9. remove() takes the key as argument, not the value. I'd wonder, if the WireArray is numerically indexed, would there be a way to use a selector to find the item to delete first?
    1 point
  10. Hi @LexSanchez made a PR to support TikTok embed, thanks for this great module!
    1 point
  11. @bernhard That's correct, a $page->extract() wouldn't be possible as the extract() function has a unique ability to create variables, as far as I understand it. The issue with extract() is that any variables it creates are unknown to your editor/IDE, and often times to the caller too. Whereas list() is defining variables in a visible manner that is readable and known to the IDE, clearly identified in the code as $variables. I rarely like extract() in code because it's too ambiguous, like tipping over a box of an unknown items and quantity. But there are times that's exactly what's intended, like in the TemplateFile class, where it has to pass an unknown set and quantity of variables to a php template file and make them directly accessible by $variables. This is fine because the php template file knows what variables to expect even if the class that provided them (TemplateFile) doesn't. So I think extract is good for cases like that, but otherwise I think it's preferable to have some kind of variable definition whether $name = 'value'; or list($name) = [ 'value' ]; etc.
    1 point
  12. thx @pwired that worked for me ? The input for the customOptions inputfield is this: enterMode: 2 how did you find that setting? I'm always lost when customizing the ckeditor...
    1 point
  13. New Dynamic Selects Here is a preview of the upcoming update to Dynamic Selects (version 008). It is still early days and I don't currently have an ETA. This upgrade redefines the 'select' in Dynamic Selects. You are no longer tied to this <select></select>. This upgrade will give developers control over how they would like to have their Dynamic Selects rendered both in the Inputfield and in the frontend. This is possible thanks to htmx and ProcessWire's TemplateFile class. These allow for partial rendering of templates generated server-side. For each Dynamic Selects data type (Page, Template, User, Field), there will be a default partial templates which receive an object of that data type. For instance, a Dynamic Select that wants to render children of a selected page will receive the PageArray containing those children at their partial template. Developers wanting total control of any partial template will only need to duplicate a partial template and save this to a designated folder under /site (similar to Padloper) and customise that as they wish. This opens up a myriad possibilities. Your markup, your way. You want to render a HTML table, fine. An accordion? Fine. A photo gallery? Why not! The above also means all ProcessWire fields, including custom ones will be supported. This is because the partial template will receive the relevant object. With custom partial templates, this leads to endless possibilities. Repeaters, complex fields, any field. You could even combine this with Padloper to allow your customers to search for or preview products in very creative ways. Because these new version uses template partials, it means you can employ access controls in any part of the Dynamic Selects , for instance, show different fields or markup depending on user's location or if logged in, etc. Using the power of htmx, it also means you can output markup to different places simultaneously (Out of Band Swaps). @999design, this could cover your need in your post above about triggering more than 1 select.
    1 point
  14. Hello, We have been audited by a security firm regarding a new website in Processwire. The client is a financial firm and insurance companies are becoming increasingly wary of the vulnerabilities that certain libraries represent. The report mentions the two obsolete jQuery libraries that ProcessWire uses for the admin part. Although the visitor or potential hackers are not aware of the use of these libraries (and the report does indicate that the site is secure), the report still mentions a moderate risk when it comes to the administration of the site. In short, the following libraries are requested to be updated to remove these vulnerabilities. .../wire/modules/Jquery/JqueryUI/JqueryUI.js .../wire/modules/Jquery/JqueryCore/JqueryCore.js It might be time to upgrade on this side. Is it possible to do this without causing problems in the administration of the site? I can do my own tests, but I would still like to know the reasons why this is not up to date.
    1 point
  15. I upgraded jQuery from 1.8.3 to 1.12.1, jQuery UI from 1.10.4 to 1.12.1, datepicker.js from 1.6.1 to 1.6.3 and updated longclick.js from 0.3.2 to 0.4.0 and it works just fine (after few quick tests). Then I tried jQuery 3.2.1 and jQuery Migrate 1.4.1 and it's working too (Migrate is required). jQuery 1.8.3 is released in november 2012. It's nothing wrong with that old version, but it just doesn't fit in the incoming new stable version of PW...
    1 point
×
×
  • Create New...