Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/02/2019 in all areas

  1. Core version 3.0.137 on the dev branch adds the ability to hook multiple methods at once, in a single call. This post details how it works and provides a useful example of how you might put it to use in your development environment. This version also refactors and improves upon several core classes— https://processwire.com/blog/posts/pw-3.0.137/
    12 points
  2. AdminBar 2.0.1 released: Plenty of updates behind the scenes. So far "end user" functionality remains largely the same, though. New options for hooking – decent support for modifying generated output and adding all-new links and other features programmatically. Extended theming support: the module now comes with three built-in themes ("original", "tires" per the theme submitted earlier by @tires, and "uikit"). Uikit is an adapted version of the top bar in admin, and it's now the default theme for the module. Each theme may include its own settings (Uikit, for an example, allows displaying/hiding some or all of its icons and the ProcessWire mark). Custom theme support is still there, but requires a few modifications: custom theme needs to be selected via module config screen, you need to provide a directory where theme files live, and this directory has to contain (at least) a theme.css file (but optionally also theme.js for custom JS, theme.php for hooks, and config.php for custom module config settings). Oh, and the module is installable via Composer now – just run "composer require teppokoivula/admin-bar" in your sites root directory, or the /site/ directory. New requirements for 2.0.1 are ProcessWire >= 3.0.112 and PHP >= 7.1.0. For earlier version of ProcessWire or PHP, use release 1.1.5 (this version won't be updated anymore, but should work in ancient version of PW and PHP). Below is a screenshot of the "Uikit" theme in action on the Wireframe website. In this case I've disabled the icons from the left side of the Admin Bar – by default each action there would have its own icon as well.
    5 points
  3. Just throwing it out there and not the answer to all PW static site situations, but a PWA like https://www.pwabuilder.com/ may help. In my experience, there can be glitches between PWABuilder depending on the config chosen, and ProCache with too much unsynched caching. Definitely not the answer if your site has lots of forms and/or dynamic content, but for static sites that have dodgy internet connections it's definitely worth investigating.
    4 points
  4. 644 means that only owner is allowed to write to the files. I'd start by checking if you already have matching files (the ones mentioned in the warnings), and if so, which user is set as their owner (and if the permissions to said files is really 644). In case the owner is not the same as the Apache user, that's likely the problem here. If you've migrated these files with the site, a safe bet would be to clear everything within the FileCompiler directory to get a "blank state" – but if permissions are too strict, that obviously won't help for long. (Note: if you sometimes run ProcessWire via CLI using the bootstrap method as another user, that can also result in these compiled files being owned by the user you've executed that CLI command with, which can cause similar issues.)
    2 points
  5. The weekend is fine. The only time I can do fun things like this. ? Maybe... in your case... take a look at /site/templates/errors/500.html That site will be shown if there are any problems with your database. I use this on "smaller" hosting solutions to prevent any issues. That 500.html can be customized a lot and therefore show an almost complete site if necessary. Contact forms don't work - or at least not out of the box - but at least a customized page shows up. Depending on how often those issues happen with your hosting, this might be a nice middle-way as it's already there. Regarding those "mysql administration things"... this shouldn't be your job. Maybe you ask and tell your hosting company about it and let them fix issues - maybe it's even better to switch to another company. In terms of ProcessWire and static sites... with the right setup it's super easy. You just have to jump some loops but after that it works fine. Depending on your OS you might need some extra steps. OSX, Linux are fine. Windows might need WSL/2 for this.
    2 points
  6. Hey folks! Took a couple of late nights, but managed to turn this old gist of mine into a proper module. The name is SearchEngine, and currently it provides support for indexing page contents (into a hidden textarea field created automatically), and also includes a helper feature ("Finder") for querying said contents. No fancy features like stemming here yet, but something along those lines might be added later if it seems useful (and if I find a decent implementation to integrate). Though the API and selector engine make it really easy to create site search pages, I pretty much always end up duplicating the same features from site to site. Also – since it takes a bit of extra time – it's tempting to skip over some accessibility related things, and leave features like text highlighting out. Overall I think it makes sense to bundle all that into a module, which can then be reused over and over again ? Note: markup generation is not yet built into the module, which is why the examples below use PageArray::render() method to produce a simple list of results. This will be added later on, as a part of the same module or a separate Markup module. There's also no fancy JS API or anything like that (yet). This is an early release, so be kind – I got the find feature working last night (or perhaps this morning), and some final tweaks and updates were made just an hour ago ? GitHub repository: https://github.com/teppokoivula/SearchEngine Modules directory: https://modules.processwire.com/modules/search-engine/ Demo: https://wireframe-framework.com/search/ Usage Install SearchEngine module. Note: the module will automatically create an index field install time, so be sure to define a custom field (via site config) before installation if you don't want it to be called "search_index". You can change the field name later as well, but you'll have to update the "index_field" option in site config or module settings (in Admin) after renaming it. Add the site search index field to templates you want to make searchable. Use selectors to query values in site search index. Note: you can use any operator for your selectors, you will likely find the '=' and '%=' operators most useful here. You can read more about selector operators from ProcessWire's documentation. Options By default the module will create a search index field called 'search_index' and store values from Page fields title, headline, summary, and body to said index field when a page is saved. You can modify this behaviour (field name and/or indexed page fields) either via the Module config screen in the PocessWire Admin, or by defining $config->SearchEngine array in your site config file or other applicable location: $config->SearchEngine = [ 'index_field' => 'search_index', 'indexed_fields' => [ 'title', 'headline', 'summary', 'body', ], 'prefixes' => [ 'link' => 'link:', ], 'find_args' => [ 'limit' => 25, 'sort' => 'sort', 'operator' => '%=', 'query_param' => null, 'selector_extra' => '', ], ]; You can access the search index field just like any other ProcessWire field with selectors: if ($q = $sanitizer->selectorValue($input->get->q)) { $results = $pages->find('search_index%=' . $query_string . ', limit=25'); echo $results->render(); echo $results->renderPager(); } Alternatively you can delegate the find operation to the SearchEngine module: $query = $modules->get('SearchEngine')->find($input->get->q); echo $query->resultsString; // alias for $query->results->render() echo $query->pager; // alias for $query->results->renderPager() Requirements ProcessWire >= 3.0.112 PHP >= 7.1.0 Note: later versions of the module may require Composer, or alternatively some additional features may require installing via Composer. This is still under consideration – so far there's nothing here that would really depend on it, but advanced features like stemming most likely would. Installing It's the usual thing: download or clone the SearchEngine directory into your /site/modules/ directory and install via Admin. Alternatively you can install SearchEngine with Composer by executing composer require teppokoivula/search-engine in your site directory.
    1 point
  7. Repeater Images Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc. When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing. Screencast Installation Install the Repeater Images module. Setup Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module. Image uploads feature There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field. To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position. It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field. New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved. Tips The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height}) https://github.com/Toutouwai/RepeaterImages https://modules.processwire.com/modules/repeater-images/
    1 point
  8. Thanks for taking on this module @teppo. A couple of minor styling observations with the Uikit theme... The spacing around the buttons is a little inconsistent. And to my eye the triangle that indicates the active button feels like it's off-centre, because the icon feels like it is separate to the word rather than them both making up a single visual unit. So for the Uikit theme I'd be inclined to centre the active marker on the word alone rather on icon + word. For pages where some buttons are not available... When "Edit" is not available the button text changes (the full stop looks out of place here), but when "New" is not available the button text is gone but the icon remains. Not sure but maybe unavailable buttons should not render at all?
    1 point
  9. Yeah, this should be an easy one. You can hook before or after AdminBar::getItems: either modify $args['strings'] before it gets passed to the method, or modify the resulting array of items before it is put to use ? Makes sense. I would definitely take a route that affects actual permissions. Since AdminBar checks Page::editable() before displaying the edit link, if this was done using permissions, I believe it should just work out of the box, i.e. the edit link shouldn't display at all ?
    1 point
  10. This reminds me of a similar Drupal module that I came across. https://www.drupal.org/project/tome https://tome.fyi/ - It takes your Drupal site and makes a static version of it. You can see a demo here: I imagine that someone with enough Processwire skills could create something similar?
    1 point
  11. Thanks, @adrian. I've been using this module for a long time, and it has actually been quite fun to work on it ? A profile edit button seems like a good idea. That was on my list for a while actually, but I wanted to get 2.x out sooner rather than later, so had to leave that for a later release ? I think we'll also need a "select enabled links/features" option to avoid too much clutter. On many (most) of the sites I've built this feature, for an example, profile edit feature wouldn't have been particularly useful – users often edit their profiles really, really rarely – so I'd like to leave it to superusers to figure out which features are necessary. (Could also make the feature selection configurable per user, if there's demand for such a feature.) Restricting editable pages to ones the user has created seems to me like a relatively specific need – at least I haven't personally come across a project where this would've been particularly useful. As such, my initial view is that this might be best implemented as a per-site customisation. Unless, of course, I'm wrong and it's actually a commonly needed feature, in which case it may make sense to add a setting for it ? Note that one key point about the hooks I've added is that it's now quite easy to customise what is displayed in the Admin Bar, and how. One example of this is what I've done with the "Uikit" theme, where I've added icons to existing items, and also the PW logo/mark as a new item. If you hook into AdminBar::getItems, you can easily modify the list, and – for an example – only show the edit link under specific circumstances. (And if this is a feature you require often, you can always bundle this, and any other modifications, into a separate module.) By the way, I'm assuming that this would actually be just about displaying the edit link – not modifying permissions? Modifying permissions would, in my opinion, definitely belong to another module. As far as I can tell, this item has been "Browse" since the beginning – at least for the past 8 years or so, according to GitHub ? I'm slightly hesitant to change what I consider established terminology. Also, I don't personally see the problem: technically what this item being active means is that you're currently browsing the site. Kind of like "browse mode" vs. "edit mode". When you're in admin and want to view a specific page, "view" is indeed better word, but in this context I actually prefer "browse". Again it's quite simple to modify this with a hook, of course, but I think I'd rather stick with current terminology for the default state.
    1 point
  12. It's great to see new life breathed into this module - thanks @teppo. Two things I added to one installation of mine was the ability to edit the user's profile and the other was to restrict them to only be able to edit pages that they have created. Would you consider adding those features? One other thought - I am a bit confused by "browse" vs the old "view" - browse to me suggests browsing through multiple pages, rather than viewing the current one which is what this link does. What do you think?
    1 point
  13. Are your PHP script and the CSV file both in UTF8?
    1 point
  14. Interesting read! Would be great to see a detailed writeup about your workflow @wbmnfktr ... Have a nice weekend ? ? ?
    1 point
  15. If it's not that urgent @elabx I can write up my setup this weekend to show you the process I established for that project. I would consider git as the established bridge to get this done. Would that work for you? In total I think it's not that much of an overhead and for experienced PW users kind of a perfect way to create static sites. @ryan pushed me into this direction with one if his comments a while back. I tried it and played around with it. And to be honest... the outcome was quite impressive.
    1 point
  16. As @teppo already mentioned: Procache or/and Cloudflare... but... If you really want to establish a static site, just use the pre-rendered files from ProCache and upload them to your host. Images/assets should already be present - to make things easier. In case of a Linux/*nix setup you might get it done with a few custom rsync/rclone/git setups to push only files that were changed/new. There is one site (a client site) I manage through ProcessWire locally, run ScreamingFrog to generate the static files and push all changes via git to the repository, which is than published by Netlify. Yes... there are a few steps involved but it's still way easier to go this way than everything else I know (Jekyll, Ghost, etc.).
    1 point
  17. Not an answer really, but technically just having ProCache could help with situations like these. The idea is to bypass PHP and MySQL entirely, after all. In fact in the past I've had a situation where MySQL was dead but the site I was monitoring kept working due to ProCache, so the issue didn't become apparent for quite a while... ? Another thing to consider would be something like Cloudflare ("always on" feature in particular), or adding Squid or Varnish (or some other proxy/cache/accelerator) in front of the site.
    1 point
  18. This is a small tutorial... If you want add another field to this fieldtype... first in FieldtypeEvents.module in getDatabaseSchema() add a line that suit your needs, so your new field gets stored to the database $schema['newValue'] = 'TINYTEXT NOT NULL'; try if you can install the module and add a field to a template and check if it works like before add the property to the constructor in Events.php $this->set('newValue', ""); then modify set() and get() so you can modify your new property... now try in your template,´if you can modify and output the new property foreach($page->events as $event){ $event->newValue = "hello new value"; echo "yes it works, we we welcome the new value: ". $event->newValue."<br>"; } if this works properly then go back to FieldtyeEvents.module: add this line in __wakeupValue() to the foreach loop $event->newValue = $v['newValue']; and in _sleepValue() 'newValue' => $event->newValue, in file InputfieldEvents.module in renderRow() method make sure, a $newValue variable gets gets sanitized from $newValue = $this->sanitizer->entities($event->newValue); change $out = " <tr class='Event$cnt $class'> <td><a href='#' class='EventClone'><span class='ui-icon ui-icon-copy'></span></a></td> <td><input type='text' name='{$name}_date[]' value='$date' class='datepicker' /></td> <td><input type='text' name='{$name}_newValue[]' value='$_newValue' /></td> //add this line add your field in __render() <table class='InputfieldEvents'> <thead> <tr class=''> <th class='EventClone'>&nbsp;</th> <th class='EventDate'>Date</th> <th class='EventDate'>newValue</th> //I´ve chosen EventDate class because its narrow and in __processInput() $event->newValue = $input->{"{$name}_newValue"}[$cnt]; I hope I didn´t forget anything, good luck!
    1 point
  19. Hi ... Jonathan Lahijani has a great tutorial on youtube that can help you Simply put, you need to create an option template, then add 2 pages, one in the page tree named options, to which you choose the option template, and under the admin add another page and change the name, for example (admin_options), so that the names are not identical. Choose a process named ProcessPageEdit and save the page ... in admin.php paste the code // Custom Options Page if( page()->name == 'admin_options' ) input()->get->id = pages()->get('options')->id; Finally, you can add some css to hide the options page in the page tree. /** Hook Admin Custom CSS */ $wire->addHookAfter('Page::render', function($event) { if(page()->template != 'admin') return; // Check if is Admin Panel $value = $event->return; // Return Content $templates = urls()->templates; // Get Template folder URL $style = "<link rel='stylesheet' href='{$templates}assets/css/admin.css'>"; // Add Style inside bottom head $event->return = str_replace("</head>", "\n\t$style</head>", $value); // Return All Changes }); You can also download the profile that has the option page created and see how you can create your own options page https://github.com/rafaoski/site-minimal
    1 point
  20. Hi @gebeer Just stumbled across this (I know my reply is a little late,) but it is totally possible to prevent your rest API endpoints from starting sessions by using the $config->sessionAllow; variable. If you define it to be a function that returns bool true or false, then it will be evaluated and the return value determines if the Session class constructor is allowed to start a new session. There's an example of it in the default wire/config.php file at line 245. Reproduced here... $config->sessionAllow = function($session) { // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // otherwise disallow session return false; }; You just need to rewrite the function so it returns false for your API endpoint path. Make that change and add it to your site/config.php file, and I think that anything hitting your API endpoint directly will not have a session created for the connection. Hope that helps!
    1 point
  21. Processwire API and minimalism is so much lean that it feels like you are still writing PHP compared to other CMS which are overly complex, I think Processwire is easy to use Project with so many things taken care of, especially the fields, It's so much easier to build applications for client easily than other frameworks/cms because Processwire provides so many features that are vital.
    1 point
  22. I just wrote that before posting it here. It didn‘t exist a few hours ago ?
    1 point
  23. I used the utf8_encode function and now the data is written correctly. This is the modified test code, if is useful for someone. <?php header('Content-Type: text/html; charset=UTF-8'); $p = new Page(); $p->setOutputFormatting(false); $p->template = 'cita'; // $p->parent = wire('pages')->get('/agenda/'); $p->name = $sanitizer->name("Solicitud de cita 20150629082201"); $p->title = $sanitizer->text(utf8_encode("Solicitud de cita de Pedro Pérez")); $p->cita_nombre = $sanitizer->text(utf8_encode("Pedro Pérez")); $p->cita_edad = 45; $p->cita_telefono = "22334455"; $p->cita_correo = "pedro_perez@hotmail.com"; $p->cita_tipo = $sanitizer->text(utf8_encode("Nueva cita")); $p->cita_otros_detalles = $sanitizer->textarea(utf8_encode("Presión alta")); $p->cita_dia_hora1 = $sanitizer->text(utf8_encode("Lunes 4:00 p.m.")); $p->cita_dia_hora2 = $sanitizer->text(utf8_encode("Miércoles 5:00 p.m.")); $p->save(); echo "La página {$p->id} fue creada!<br>"; ?> Thanks
    1 point
×
×
  • Create New...