Jump to content

protro

Members
  • Posts

    84
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by protro

  1. Thanks for your response @wbmnfktr … I am aware that these things can be done with css/js … I was more interested in trying something outside my familiarity with php. Here's a follow-up question: how can I write a custom function and access it in a template file in Processwire? Inside of _init.php I have added a user-agent regex for mobile detection <?php namespace ProcessWire; // Optional initialization file, called before rendering any template file. // This is defined by $config->appendTemplateFile in /site/config.php. // Use this to define shared variables, functions, classes, includes, etc. function isMobileDevice() { // Get the user agent string $userAgent = $_SERVER['HTTP_USER_AGENT']; // Check if the user agent matches any common patterns for mobile devices if (preg_match('/android|iphone|ipod|blackberry|iemobile|opera mobile|palmos|webos/i', $userAgent)) { return true; } else { return false; } } So why do I get: Call to undefined function isMobileDevice() when trying to access this function with inside of a .latte template: {if isMobileDevice()} I might be missing something very simple. This is some new territory for me. With thanks,
  2. Hello PW forums, I am using PW & Rockfrontend with the Latte template engine. I see there used to be a mobile detect module but it is no longer available. Is there a way to accomplish simple mobile detection using php in Processwire 3.x.x ? Thanks,
  3. Thank you for this terrific module. Sorry if basic question: What is best methodology for simply updating the database on a production server if the rest of the site content / processwire core have already been deployed?
  4. Any good strategies for avoiding FOUT (Flash of unstyled text) when using Rockfrontend? I am loading the styles as in your video tutorial in the <head>: $rockfrontend ->styles()->setOptions(['autoload'=>true]) // ->add("/site/templates/uikit-3.15.10/src/less/uikit.theme.less") ->add("/site/templates/styles/custom.less") And then before </head> I import the Google Fonts <!-- fonts --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?&family=Major+Mono+Display&family=Oswald:wght@200;300;400;500;600;700&family=Silkscreen&display=swap" rel="stylesheet"> Wonder what some possible solutions would be. I tried display=block but that causes layout inconsistencies on page load. Any solutions or techniques much appreciated.
  5. I am trying to retrieve a config value to be shared with javascript using a $config->js() declaration at the top of _main.php: $config->js('mySettings', [ 'lightLogo' => $pages->get('logo-alpha-light')->image->url, 'darkLogo' => $pages->get('logo')->image->url, ]); in main.js when I try to access mySettings the console shows: ReferenceError: ProcessWire is not defined What am I missing? This is the first line in main.js var mySettings = ProcessWire.config.mySettings;
  6. Hello Processwire peoples. I am a new user and very much enjoying the possibilities afforded by this CMF. I was trying to accomplish $page->children() but exclude returned pages that themselves contained children (I am calling them grandchildren here). I came up with this finally, which seems to work. It excludes the child page that contained children and merges its children with the rest of the original page's children, and sorts in descending chronological order. I am using Rockfrontend and Latte: {var $children = $page->children()->not("children.count>0")} {var $grandChildren = $page->children("children.count>0")->children()} {var $items = $children->append($grandChildren)->sort("-date")} {foreach $items as $item} I find the documentation here a bit confusing. For example I wish I had a list of the system fields belonging to a page. I have trouble locating what the available selectors are. Any help or alternatives much appreciated ?
×
×
  • Create New...