Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/01/2018 in all areas

  1. This week flew by too fast. I did some work on the core, but mostly had to focus on some end-of-the-month client work deadlines, in ProcessWire-powered projects. As a result, I don't have enough core updates to warrant a version bump on the dev branch this week, so putting a quick update here rather than a blog post. ProcessWire 3.0.112 should be ready by this time next week. One of my clients recently requested a URL field that intermittently verifies itself—to make sure that the URL is still returning a 200 success, and not a 404 error, or some other error code. Their site has thousands of external URLs (more than they can check manually), and they want some way to avoid showing links for URLs that are no longer working. I thought a self-healing URL field sounded like a cool idea, so put a little work into that this week, and will likely finish it up next week. The module is called FieldtypeVerifiedURL and it extends the regular FieldtypeURL field, except that in its configuration you can specify how often you want it to verify that the URL is still valid. It also performs the verification whenever the value changes. It uses WireHttp to obtain and store the response code with the field, whether a 2xx (success), 3xx (redirect) or 4xx (error) code. So if you wanted to, you could filter the pages with this URL field by response code (like to find all those returning 404s for instance). It can optionally save the <title> tag found at the URL for you as well. In our case, we will be configuring it to check that URLs are valid once a week, and this is something that it will do in the background automatically. When a URL is found to be returning an error code (like a 404), the output of the field can be optionally configured to return an empty value rather than the URL (when output formatting is on). I'm not anywhere near finished with this one, but if this sounds useful to you, stay tuned for more on this soon. Have a great weekend!
    11 points
  2. I would have multiple uses for this type of URL field for sure! At the moment I use @teppo's unreleased ProcessLinkChecker, which is awesome. I think the key thing would be that in addition to returning an empty value I think it also needs a way to log and also report (maybe via email or other options) broken links so that we don't need to monitor its findings.
    5 points
  3. code: https://processwire.com/talk/topic/12081-ad-banner-module-with-click-through-rates/
    3 points
  4. Hello for all, ConfigurationForm fieldtype module is one my experiment from 2016. Main target to build this module was to store multiple setup and configuration values in just 1 field and avoid to use 1 db table to store just single "number of items on page", or another db table to store "layout type" etc. Thanks to JSON formatted storage this module can help you to reduce number of PW native fields in project, save DB space, and reduce number of queries at front-end. Install and setup: Download (at the bottom ), unzip and install like any other PW module (site/modules/...). Create some filed using this type of field (ConfigurationForm Fieldtype) Go to field setup Input tab and drag some subfields to container area (demo). Set "Name" and other params for subfields Save and place field to templates ("Action tab") How to use it: In my case, I use it to store setup and configurations values, but also for contact details, small content blocks... (eg. "widgets"). Basic usage example: ConfigForm fieldtype "setup" has subfields: "limit", type select, option values: 5, 10, 15, 20 "sort", type select, option values: "-date", "date", "-sort", "sort" // get page children (items) $limit = isset($page->setup->limit) ? $page->setup->limit : 10; $sort = isset($page->setup->sort) ? $page->setup->sort : '-sort'; $items = $page->children("limit=$limit, sort=$sort"); Screenshots: Notes: Provide option to search inside subfields Provide multilanguage inputs for text and textarea field types Provide option for different field layout per-template basis Do not place/use field type "Button" or "File input" because it won't works. Please read README file for more details and examples Module use JSON format to store values. Text and textarea field types are multilanguage compatible, but please note that main target for this module was to store setup values and small content blocks and save DB space. Search part inside JSON is still a relatively new in MySQL (>=5.77) and that's on you how and for what to use this module. Thanks: Initial point for this fieldtype was jQuery plugin FormBuiled and thanks to Kevin Chappel for this plugin. In field type "link" I use javascript part from @marcostoll module and thanks to him for that part. Download: FieldtypeConfigForm.zip Edit: 14. August 2018. please delete/uninstall previously downloaded zip Regards.
    1 point
  5. Sorry I took a while to respond... some appliances in the house broke that needed fixing and got a new Roland electronic drum kit, which I told the wife was more for my boys, but I have been hogging it... ? Site still isn't finished, but almost... I tried to put together a video which shows: Creating a new test page Using repeater matrix field to add different content to the main body of the test page Creating a new page widgets group and a slideshow widget Creating a new test template page using the UIKit framework as the container for the widget Targeting specific / all pages to show the container Adding some classes to the container So I hope this shines some light on how I use this... kinda the best of both worlds... I can add main page content via repeater fields, but if I need content anywhere else, I can build out the template and target where I want the widget to go for any pages outside the main page content, or use the same widget in different locations on selected pages. I think I will try using fieldsetgroup or fieldsetpage, (I think) to try to combine the repeater matrix fields used for the main content and the widgets, so I really only have to maintain one template section and a single bit of code, if it needs expanding or more features are requested by a client.
    1 point
  6. I could use a field like this. I have a directory of local businesses and non-profit organisations, but sometimes their websites change or they go out of business, so it would be really handy to be able to run an automated script that can either hide or un-publish any listings that don't have a valid address. That would save on manually checking every one on a periodic basis to make sure they still exist. Of course I'd probably still double check manually any that get deactivated before removing them, but it would make the process a lot more efficient.
    1 point
  7. I see your point for sure. I guess I thought it was more about ensuring the default panels on the local install vs a live one. If you're migrating a database between the two, Tracy settings could get mixed up easily, but by using the config.php file you can more easily keep track of these. You could even use PW's built-in config-dev.php file to ensure that locally the mailInterceptor is loaded, but not on the live server. I think if we need to prevent some panels from being adjusted via the debug bar's Panel Selector, then this needs to be a new config setting where you can select all the panels that you want excluded from the Panel Selector interface. This list of panels could of course be set in the config settings, or it could also be done via: $config->tracy = array( 'nonToggleablePanels' => array('mailInterceptor') ) What do you think about this option - this would make it very difficult to accidentally remove the Mail Interceptor panel. I think perhaps it would also be worth adding a few extra settings to config-dev.php so it looks like this: $config->tracy = array( 'enabled' => true, 'guestForceDevelopmentLocal' => true, 'frontendPanels' => array ("mailInterceptor","processwireInfo","requestInfo","processwireLogs","tracyLogs","methodsInfo","debugMode","console","panelSelector"), 'nonToggleablePanels' => array("mailInterceptor", "tracyToggler") ); This setup would ensure that Tracy is always enabled, the Mail Interceptor panel is on and can't be toggled off, and the Tracy Toggler panel/button can't be enabled. The only remaining way to disable Tracy would be via the Disable Tracy button on the Panel Selector, but I would add an option to remove this as well. @Ivan Gretsky - is this the sort of functionality you would need to feel comfortable with this approach? The other consideration in all this is the load order of modules by PW. The hook that intercepts emails from being sent is in Tracy's init() method, but I suppose if you have another module sends an email in init(), rather than ready(), then it's possible it could be sent before Tracy intercepts it, but that like a highly unlikely situation.
    1 point
  8. The most recent version includes @Robin S's suggestion for "Expand/Collapse All" functionality. Both Robin and @tpr have helped significantly with testing of this feature - thank you both. Also new in this version is the ability to override any module config settings using: $config->tracy = array() You can read more about this and why it was introduced here:
    1 point
  9. Just to correct, if you have edit right and a language or page is unpublished you still can see it if logged in. It's just that maybe something like the language nav that wouldn't show the switch link for that language, but it can be coded to be seen by editors.
    1 point
  10. Thanks to @dragan ... It looks like it's okay now after adding the margin auto to the grid /* eliminate horizontal scrollbars */ .grid { margin-right: auto; margin-left: auto; }
    1 point
  11. You got me thinking. I do work as a single developer, but increasingly I'm finding I want to deploy solutions I've developed for one project to another, and just copying and pasting via the admin isn't ideal. I was having a look at Silverstripe recently, as I have a possible project where Processwire, though I'm sure can do the job, might meet some resistance, whereas Silverstripe will almost certainly be accepted as it's mandated as the CMS of choice by government here (NZ). What struck me is that you can do far more with Processwire with less coding, but in some cases defining data structures via coding rather than via an admin UI may be more appropriate for sharing code between projects or in the case of a team between team members. Processwire is perfectly capable of doing this as the admin UI is just a layer on top of the API, so there's no reason why fields and templates can't be defined programmatically in modules that are subject to version control. I notice that some of the existing modules actually consist of several dependant sub-modules, bundled in a common folder, so it would be easy to set up something like this with git version control. Silverstripe automatically rebuilds database schema by using a /build URL, however it doesn't remove unneeded fields or tables after a schema change, whereas the Processwire API makes it fairly easy to both add and remove fields via a module. Processwire will detect changes to a module version, and run any update process automatically, so even though it bypasses the ease of use of the admin UI, developing your database schema programmatically in modules might ease collaborative development.
    1 point
  12. The company which I'm working for develops apps, too. And for one of them we need a little notification system. Just a little endpoint which returns json. The app saves all notes which have been sent to the user. To be able to identify which message has already been shown, we need a global identifier. The workflow is as follows: Login PW Admin add a new page, the "id" field will be populated with a GUID fill in all other fields which should be sent an endpoint returns json, for example something like the following [ { "id":"936DA01F-9ABD-4D9D-80C7-02AF85C822A8", "url":"https:\/\/domain.com\/endpoint\/notice1\/", .. }, { "id":"A36DA01F-9ABD-4D9D-80C7-02AF85C822A8", "url":"https:\/\/domain.com\/endpoint\/notice2\/", .. } ] as you can see, for each note there's a "detail" page which will return the actual message if someone opens the app, it checks whether there are new notes and displays them
    1 point
  13. I can confirm the same setup is very easy to count clicks + views...i need that for a project. Working good so far. Only difference is that i simple count clicks and views in a integer field without additional information - so it is "data economical" and i've no problem with saved IP's and so on... For manging the banner i use a PageTableExtended Field: I've a general settings about the amounth of ad slots on that page - and a flag option on every single page where a user can set ads to off for a single page. /** * Adsystem show Ads in several templates * * @var $limit (Int) set the limit of displayed ads ->look at anzeige_anzahl /settings/werbeanzeigen/ * @var $headline (string)set the headline of the ad list */ function renderAdsystem($headline = 'Anzeigenpartner') { //get all ad pages on basic setting - unpublished pages are not listed.... $limit = wire('pages')->get('1056')->anzeige_anzahl; //build add output $anzeigen = wire('pages')->find("template=part_ad, limit={$limit}, sort=random"); //render ads and collect them in $all_ads $all_ads = '<h4 class="subtitle">'.$headline.'<h4>'; foreach ($anzeigen as $anzeige) { $anzeige->of(false); $anzeige->anzeige_views += 1; $anzeige->save(array("quiet" => true, "uncacheAll" => false)); $anzeige->of(true); //get the right imagesize $anzeige_bild = $anzeige->anzeige_bild->size(260,120); //build ad link $all_ads .= '<a href="'.$anzeige->url.'" alt="'.$anzeige->title.'"><img class="anzeigen" src="'.$anzeige_bild->url.'" alt="'.$anzeige->title.'"></a>'; } //check if adds are off if ($limit == 0) { $out = ''; } else { $out = $all_ads; } return $out; } All is a page - so the adlink is a page for shure - and for pages we can count clicks == pageviews + redirect and views for every rendering that pageitem somewhere. Just as an addition to the great example from BitPoet! Thanks for that - so i'm tranquilised to find a way that a professional find, too - so it couldn't be that wrong Best regards mr-fan
    1 point
  14. My solution, which works nicely: I put the following code on the top of my template. (example for French as default, German and English) $date_lang = array(); switch ($user->language->name) { case 'en': setlocale(LC_ALL, 'en_GB'); $date_lang[0] = "%A %B %eth %Y at %I:%M %p"; $date_lang[1] = "%B %eth %Y"; $date_lang[2] = "%I:%M %p"; $date_lang[3] = "%A"; break; case 'fr': setlocale(LC_ALL, 'fr_FR'); $date_lang[0] = "%A %e %B %Y à %kh%M"; $date_lang[1] = "%e %B %Y"; $date_lang[2] = "%kh%M"; $date_lang[3] = "%A"; break; case 'de': setlocale(LC_ALL, 'de_DE'); $date_lang[0] = "%A, den %e. %B %Y um %k.%Mh"; $date_lang[1] = "%e. %B %Y"; $date_lang[2] = "%k.%Mh"; $date_lang[3] = "%A"; break; default: setlocale(LC_ALL, 'fr_FR'); $date_lang[0] = "%A %e %B %Y à %kh%M"; $date_lang[1] = "%e %B %Y"; $date_lang[2] = "%kh%M"; $date_lang[3] = "%A"; } Then I created a page field, where I store a date unformatted (go to setup->fields->mydatefield->details-> date output format ->"None"). getUnformatted() is only needed, if the date is stored formatted. Finally I can insert the date like echo strftime($date_lang[0], $mydatefield); /* output(de): Freitag, den 11. Oktober 2013 um 12.52h * output(fr): Vendredi 11 octobre 2013 à 12h46 * output(en): Friday October 11th 2013 at 12:46 pm */ echo strftime($date_lang[1], $mydatefield); /* output(de): 11. Oktober 2013 * output(fr): 11 octobre 2013 * output(en): October 11th 2013 */ echo strftime($date_lang[2], $mydatefield); /* output(de): 12.52h * output(fr): 12h52 * output(en): 12:52 pm */ echo strftime($date_lang[3], $mydatefield()); /* output(de): Freitag * output(fr): Vendredi * output(en): Friday */ Maybe you have to check out which string in setlocale is working on your Server. Try different: setlocale(LC_ALL, array('fi_FI.UTF-8','fi_FI@euro','fi_FI','finnish')); //put out the first supported string echo setlocale(LC_ALL, 0);
    1 point
×
×
  • Create New...