Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/09/2023 in all areas

  1. Got a support request from @dotnetic today and thought I'd share it with you ? Imagine you have all speakers saved under /speakers with template "speaker", eg /speakers/someone and /speakers/anotherperson Now you want to show/list those persons in the RockPageBuilder block called "Speakers". That's very straightforward ? In Speakers.php you add a helper method: <?php ... class Speakers extends Block { ... public function allSpeakers() { return $this->wire->pages->find("template=person"); } } And in the view file Speakers.view.php: <ul> <?php foreach($block->allSpeakers() as $speaker): ?> <li><?= $speaker->title ?></li> <?php endforeach; ?> </ul> Or when using LATTE in Speakers.latte: <ul> <li n:foreach="$block->allSpeakers() as $speaker"> {$speaker->title} </li> </ul>
    2 points
  2. Hi @antoine.ctrs, did you read MAMP Pro documentation first? Setting a server environment is not specifically related with ProcessWire. You can test your installation with a simple index.php and a phpinfo() call. When it works, try with ProcessWire (unzip folder in a served directory and go to this URL with your browser).
    1 point
  3. @Klenkes thx for the report. Seems you are trying out things that all of us have never been using over the last 3 years ? Could you please try changing line 81 from $nullpage to $block: $f = $field->getInputfield($block); Edit: Sent you the new version as PM, please check ?
    1 point
  4. I love ChatGPT when it comes to doing weird things in JavaScript. For example, there's a 3rd party service a client of mine is using that allows you to load in custom JS and CSS to customize the appearance of their platform more to your liking. The HTML of the 3rd party service is lacking in some CSS classes on some elements, so I can't hook into those elements to style them more precisely. To further complicate things, those elements only appear after an AJAX request is done. So I needed to add extra classes on particular elements in the HTML every time an AJAX request was made. I don't keep up with JS, but after giving it a nice prompt, BOOM, there's the answer with MutationObserver, XMLHttpRequest and addEventListener. This literally saved me a day, if not more, and tons of headache.
    1 point
  5. Quick thought - could you check your server has a time sync service enabled (ntpd, chronyd or systemd) and that the time is accurate on the server. Perhaps you could update the ProcessLogin.js code to console.log(startTime) as well, and post the results here? Maybe compare it with console.log(new Date().getTime()) from your browser console. Then we can get a feel for how far out of step the server and browser times might be?
    1 point
  6. Hi @tourshi, welcome to PW. If you want do "things" with / from a page in a function, you best pass the $page as parameter or get its handle with the wire() function: function getTitle($page) { $t = $page->title; function getTitle() { $page = wire("page"); $t = $page->title; But if you only want one of two field values, depending if it is populated or not, as I can see from your code, you don't need a function for that. You can use it directly in your template with an OR selector as follows: $t = $page->get("long_title|title"); This will give you the value of long_title if there is one, OR, if it is empty, it gives you the value of title. Coming back to the function: fastest way is to pass the variable into the function, because the variable is an object what is passed by reference. There is no drawback or overhead, its the fastest way. If you, for what ever reason, cannot pass a API variable to a function, you always can get there handles via the wire("nameofapivar") function. This works everywhere, but has a (very little) overhead. Also I don't think it is measurable with a few calls, (less than 100).
    1 point
×
×
  • Create New...