Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/17/2023 in all areas

  1. As far as I know (and I haven't used this feature yet!) this should be possible (found here: https://processwire.com/modules/rock-frontend/) You can make use of the addIf() function to load a script only under special circumstances. Adding assets to your site (JS or CSS) While you can always add custom <script> or <link> tags to your site's markup it is recommended that you use RockFrontend's AssetsArray feature: $rockfrontend->scripts() ->add('/path/to/your/script.js') // you can add any custom flags to your $rockfrontend variable at runtime! ->addIf('/path/to/foo.js', $rockfrontend->needsFooScript) ->addIf('/path/to/slider.js', $page instanceof HomePage) ->addIf('/path/to/blogscript.js', $page->template == 'blogitem') ; $rockfrontend->styles() ->add(...) ->addIf(...) ; There are several reasons why this is preferable over adding custom script/style tags: addIf() keeps your markup file cleaner than using if / echo / endif It automatically adds timestamps of files for cache busting You can inject scripts/styles from within other files (eg PW modules) RockFrontend itself uses this technique to inject the styles and scripts necessary for frontend editing (ALFRED). Have a look at the module's init() method!
    2 points
  2. Disclaimer: As someone new to PW, I wouldn't consider this an answer but a little help on moving forward. Check out the selector section of docs: Using selectors in ProcessWire CMS An example find - would get items that match River on the "parent" and items that match Dinner-Plated on the child. $results = $pages->find('template=venue-area|function-type, (function=River), (type=Dinner-Plated)'); There are endless possibilities with the selectors so that's just one way. Each result (say you're looping $result as $item) would have things like $item->parent, or $item->children. For example, you can do $item->parent->title. I don't know if you're using repeaters, page refs or any of the fields so the selectors could vary wildly. Either way, that selector page has a lot of great details. As for unwieldly results, hopefully a more seasoned person can add some guidance. It may be best to do more than one selector depending on the structure and complexity of searches. How many sections, search criteria and results are you expecting? As a parting note, I would strongly suggest you have Tracy Debugger installed > Tracy Debugger (TracyDebugger) - ProcessWire Module. The page dumps alone are lifesavers.
    2 points
  3. In a recent GitHub issue report, I was asked about output formatting in ProcessWire, and where more information could be found about it. I know I've written about it numerous times, and went to locate the documentation page, only to find we didn't have one! Output formatting is such an important topic, so here is everything you need to know. I hope you'll find it simple enough, but also useful and thorough— https://processwire.com/blog/posts/output-formatting/
    1 point
  4. I seem to have a few pages which show they have been modified recently by 'guest'. However, they appear to be unchanged and the related templates have set guest access to view only. I thought it might be something to do with page hit counters, but that seems not to be the cause. Some of the pages are only archives and are not directly accessible from the website (i.e. can't be retrieved by following links from the home page), so it seems a bit like a bot, but surely it should not mark the pages as modified? Any ideas?
    1 point
  5. I don't understand what you are saying here. And it sounds totally contrary to what you say afterwards. RockFrontend's "addIf()" for adding single scripts depending on conditions is one thing, but replacing the whole markup is something totally different. If you are trying to do the latter you have two options. One is what you describe and make ProcessWire NOT use the _main.php file. Another option would be to be more explicit in _main.php and put something like this on top of the file: <?php if($page->template == 'foo') return $rockfrontend->render('my/custom/markupfile.[php|latte]'); ... // content of _main.php here that will be loaded for all templates except 'foo' Another concept that RockFrontend provides is the renderLayout() method. The concept is to put this in _main.php: <html> <head>...</head> <body> <?= $rockfrontend->renderLayout() ?> </body> </html> Which will tell RockFrontend to load /site/templates/layouts/default.php by default and load /site/templates/layouts/foo.php for all pages with template "foo". So you have lots of options ?
    1 point
  6. Dear all, just released version 1.0.1 of my ProcessWire site module NoCookieWithoutConsent on the ProcessWire module repository. Added the option to specify URL segments for the optional imprint and privacy policy page via the module configuration in the backend. If the URL segments are set, the link to the specified page will be shown in the footer of the cookie consent dialogue. If no URL segments are specified, no links are shown at all (default). As the module runs without issues on some client sides already, I pumped the version from v0.0.2 to v1.0.0 (quickly followed by v1.0.1 fixing an overseen hardcoded URL). Have fun.
    1 point
  7. I'm on a mobile, so can't test this but you could try the following... Create a dummy SVG file with a placeholder icon and module name all aligned and styled properly. Give the placeholder icon and text span containing the changable module name unique IDs. I assume the real icons are also SVG (e.g. FontAwesome) and not an image? On page save (with PHP, I assume), open the dummy SVG and regex search-replace the icon (open the icon code too if necessary) and module name. Save new code as a new SVG file. That would be my stating point.
    1 point
  8. I'd love to help, but I don't think I understand the question. This would be very easy: <?php foreach($pagearray as $page) { echo "<div>Parent: ".$page->parent->title."</div>"; echo "<div>Grand-Parent: ".$page->parent->parent->title."</div>"; } But I think that was not your question, was it? I guess your code-block with all the venues has some meaning as well, but I can't imagine what exactly you are asking for. And I also don't understand what exactly you mean by things becoming "unwieldy" at some point? If you are asking for some kind of search engine that's a whole other topic and can quickly become a lot more complex depending on what you need or want, but then again you'd have to be a lot more specific with your questions (at least for me to understand, maybe it's clear for others already). In general looping through pages and requesting data from parent or grandparent pages via API means that you load pages into memory. That can be inefficient if you are dealing with lots of pages. That's why I have built RockFinder and later we got findRaw() in the core. Both can load lots of data with an efficient and fast SQL query rather than loading everything from PHP. That's especially handy if you work with tabular data like data grids or such where pagination and sorting is done on the client side. For search results you could also add pagination and limit the number of results to 20 for example, then it shouldn't really matter if you load data via SQL directly or you loop some pages via PHP.
    1 point
  9. Thank you Ryan! I have been dilligently but blindly turning Output Formatting on and off in my code for years now, it's nice to know how it all works below the hood. ?
    1 point
  10. @strandoo without brainstorming a lot, you could setup an hidden pre-filled field. You certainly want to use `processLoginForm()` and optionnaly `loginSuccess()` hooks. Example there on this old thread, feel free to ask for help: Edit: I highly suggest you to buy a license for the Pro version if your project can afford it, the module is safe, but when dealing with secure access, you want something maintained. You will have possibility to ask ryan directly, and it's a way of "sponsoring" Ryan dev, without speaking of the benefit to the community. ? ... comes from the company’s Managing Director (you want to keep a good reputation ?) That was my positive comment of the day ?
    1 point
  11. You can also use $sanitizer->entitiesMarkdown(), either for basic markdown or full markdown by setting the options argument to true.
    1 point
  12. Default session lifetime is 86400 seconds. You can change this to any value you want. // config.php $config->sessionExpireSeconds = 86400; Allow/ disallow sessions (and the wire cookie) under conditions. Remind that you need this to have access to the backend admin. // config.php $config->sessionAllow = true; If you want to disable cookies only for the frontend /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // otherwise disallow session return false; }; If you want to use cookies respecting EU Cookie law I recommend Cans Module MarkupCookieConsent in combination with this settings. /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // user accepted cookies due to EU law (Module MarkupCookieConsent) if(!empty($_COOKIE['eu-cookie'])) return true; // otherwise disallow session return false; }; Use the core module SessionHandlerDB to store session vars in the database. Learn more about session setting options and sessions by reading the comments in the files /wire/config.php or /wire/core/Session.php of your processwire installation.
    1 point
  13. That would disallow all attributes (id/class/src/href) as well. Disallowing *{*} should be enough because it's preventing everything besides an empty style tag.
    1 point
×
×
  • Create New...