Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/29/2020 in all areas

  1. FWIW, we needed to preserve query string parameters (mostly UTM params for campaign tracking) with a lot of permutations, and after trying a few different things, we ended up adding this bit to init.php. It seems to be working well for our particular use case. // Hook the 404 routine to catch valid URLs with UTM params. $this->addHookBefore('ProcessPageView::pageNotFound', function($event){ // Get the originally requested URL and its query string. // $_SERVER['QUERY_STRING'] is not reliable in this environment. $source_url = parse_url($_SERVER['REQUEST_URI']); $source_path = $source_url['path']; $source_querystring = $source_url['query']; // Do nothing if there is no query string. Jumplinks can manage that. if(!isset($source_querystring)) return; // See if we have a jumplinks entry for the source path WITHOUT the query string. $db = wire('database'); $source_string = trim($source_path, '/'); $sql = "SELECT source, destination FROM process_jumplinks WHERE source = '".$source_string."/?'"; $result = $db->query($sql); $match = $result->fetch(\PDO::FETCH_ASSOC); // If any matches are found, try redirecting to it, appending the original query string. $target = $match['destination']; if($target != ''){ // is this a path or a page ID? if((strpos($target, 'page:') !== false)){ $id = (int) ltrim($target, 'page:'); $page = wire('pages')->get($id); $target_url = $page->url.'?'.$source_querystring; }else{ $target_url = '/'.str_replace('{!all}','',$target); $target_url .= '?'.$source_querystring; } // wire('log')->save('querystrings', 'Source: '.$source_path.', Target: '.$target_url); wire('session')->redirect($target_url); } }); Maybe others will find it helpful.
    2 points
  2. Is Counting a text field? I imagine you want to do something like: "some text $articles some more text". If so, you can use the Hanna Code module, or even a simple string replace, by preparing the text in the field with a placeholder tag: "some text {articles count} some more text", and in your code: <h3><span class="counter"><?=str_replace("{articles count}", $articles, $counter->Counting)?></span><span class="plus-icon">+ </span></h3>
    2 points
  3. The config option for this duration is now included in 0.2.3 ?
    2 points
  4. This one: https://github.com/processwire/processwire/blob/dev/wire/modules/Process/ProcessPageList/ProcessPageList.js So, jQuery mainly and some vanilla JS.
    2 points
  5. I suggest that first you find the error in the HTML as delivered to the browser, and then work out the source of the error. View the source of the page or your browser's developer tools ("Inspect"). If you can't work it out, try an HTML validator (e.g. https://validator.w3.org/). An <a> element within a <p> is certainly OK. With any luck, once you know what the error is, the cause will be reasonably clear. As a total guess, I suspect it'll be something in your template file.
    1 point
  6. @adrian Hi Adrian, the latest version is throwing a warning if there are no external panels: I think this will only occur if there are no external panels, if the glob pattern is empty static::$externalPanels will be undefined (see TracyDebugger.module.php#L320-327). Should be fixed by initializing $externalPanels to an empty array (see L143). Thanks!
    1 point
  7. I'm on mobile but it looks your server is missing the PHP mbstring extension. Install that and you should be fine.
    1 point
  8. When I started working professionally on web projects... (don't you just love when folks start with that? "oh man, it's going to be another rant!") ... some of the first CMS' I had the pleasure to work with were kind of "static site generators": they generated static HTML files when you saved the content, and if your site had subdirectories, those were literal directories on the disk with more HTML files in them. I believe this was in part because server-side rendering back then was pretty darn slow and clunky, but also because it was easier to build a clean site structure with actual directories filled with static HTML files. "Dynamic" features, comment forms, polls, and whatnot were not quite as important back then, mind you. Now, I get that modern SSG's are a different beast in many ways, and I think they're actually pretty rad. What bugs me, though, is the amount of marketing bullsh... uhm, opinionated information floating around. Things like this gem from the staticgen.com website (emphasis added): I mean... how is this what a "typical CMS driven website" looks like? Any half-decent CMS has built-in caching support, at least to some extent, and caching plugins regularly pop up amongst those lists of most popular plugins for platform X. You don't need to be a rocket scientist to figure out that running a server-side rendered, CMS generated website with no caching whatsoever is a Very Bad Idea™. Comparisons like this may make the SSG approach sound good, but they've also got little to do with how things actually work. Without hopefully being too blunt, I don't think this is necessarily the best question to ask. If you define SSG as an application that reads markdown files from disk and generates a static site from those (that's one of the first definitions that comes up if you search for the term) then I don't see this as a solution most of us could push to our clients. At least not unless the site in question is a static one that doesn't need to update too often, and/or you can convince the client to pay you for each modification on a case-by-case basis. On the other hand if you think of an SSG as something that generates static site from dynamic content managed by some piece of software, well... that software you use to generate the content for the SSG? That's a CMS. It may be a headless CMS, but a CMS nevertheless ? I'm also going to agree with @MoritzLost on the point that ProcessWire + ProCache is indeed a kind of an SSG. Keeping a few potential pitfalls in mind one could definitely use this combination to build a setup that pre-renders the whole site and thus doesn't depend on request time server-side rendering. The web is full of interesting tech: headless CMS', static site generators, APIs, and whatnot. While the "best" choice depends on the use case — you would have to consider the pros vs. cons and figure out what's best for each particular project, client, and team — in my opinion it's also rarely all that important. Websites are created for end users and end users don't care what you're running the site on — as long as it works, serves their needs, is fast (enough), etc. ... and you can get that with any platform ? Sorry, that last part was a bit off-topic. Overall the SSG market is well worth keeping tabs on. Personally I tend to lean on the "dynamic CMS generated content rendered server-side with efficient caching policy" approach, but that's mostly because I feel it makes sense for the kind of projects and clients I tend to work with. Pros and cons ?‍♂️
    1 point
  9. Hello, Just a mention that today I have received this newsletter from The Whale : https://thewhale.cc/91 And Processwire is part of it ?
    1 point
  10. I've been running MariaDB 10.2 on CentOS with Plesk for a while, and I don't think I recall any issues.
    1 point
  11. ProcessNetteTester Run Nette Tester tests within ProcessWire admin. (continued from here) Features AJAX interface for running Nette Tester tests, in bulk or manually display counter, error message and execution time in a table run all tests at once or launch single tests show formatted test error messages and report PHP syntax errors stop on first failed test (optional) hide passed tests (optional) display failed/total instead passed/total (optional) re-run failed tests only (optional) auto scroll (optional) include or exclude tests based on query parameters start/stop all tests with the spacebar reset one test or all tests (ctrl+click) TracyDebugger File Editor integration https://modules.processwire.com/modules/process-nette-tester/ https://github.com/rolandtoth/ProcessNetteTester
    1 point
  12. It seems that the user needs to have the page-edit permission for both the parent page and the child page in order to sort the child page. I hadn't noticed this before. It's a shame that the page-sort permission can't be granted independently of page-edit as it seems like they involve quite different levels of risk/responsibility. I opened a request at GitHub: https://github.com/processwire/processwire-requests/issues/290 As for a hook you could use this in/site/ready.php: // Just for your target role if($user->hasRole('editor')) { $wire->addHookAfter('ProcessPageEdit::execute', function(HookEvent $event) { /* @var ProcessPageEdit $ppe */ $ppe = $event->object; $page = $ppe->getPage(); // The names of templates that the user is not allowed to edit $disallowed_templates = ['colours', 'colour']; if(in_array($page->template->name, $disallowed_templates)) { // Replace the Page Edit markup $event->return = 'You do not have permission to edit this page.'; } }); } This may not be 100% secure in that a person could theoretically create their own edit form in their browser dev tools (although I think that's a very unlikely possibility). But if you wanted to be extra safe you could follow an alternative approach of limiting access at the field level for all the fields in the relevant templates. Depending on the number of fields that could be a hassle via the admin interface so you could look into doing it via the API.
    1 point
×
×
  • Create New...