Jump to content

Sergio

Members
  • Content Count

    513
  • Joined

  • Last visited

  • Days Won

    11

Sergio last won the day on June 16

Sergio had the most liked content!

Community Reputation

723 Excellent

1 Follower

About Sergio

  • Rank
    Hero Member
  • Birthday 04/13/1979

Profile Information

  • Gender
    Male
  • Location
    Leiria, Portugal

Recent Profile Visitors

8,083 profile views
  1. Hi @kongondo, sure, but he mentioned "logged-in users can publish posts" so I think he can capture the user timezone settings on the server side, and/or, give the user to overwrite this preference on admin. EDIT: sorry, I misread it. You are right, @kongondo! my bad!
  2. I would go with the great Carbon library and handle the timezone conversion in PHP. https://carbon.nesbot.com/docs/#api-timezone $tz = new CarbonTimeZone('Europe/Zurich'); // instance way $tz = CarbonTimeZone::create('Europe/Zurich'); // static way // Get the original name of the timezone (can be region name or offset string): echo $tz->getName(); // Europe/Zurich echo "\n"; // toRegionName returns the first matching region or false, if timezone was created with a region name, // it will simply return this initial value. echo $tz->toRegionName(); // Europe/Zurich echo "\n"; // toOffsetName will give the current offset string for this timezone: echo $tz->toOffsetName(); // +02:00 echo "\n"; // As with DST, this offset can change depending on the date, you may pass a date argument to specify it: $winter = Carbon::parse('2018-01-01'); echo $tz->toOffsetName($winter); // +01:00 echo "\n"; $summer = Carbon::parse('2018-07-01'); echo $tz->toOffsetName($summer); // +02:00 // With no parameters, a default timezone is created: echo new CarbonTimeZone(); // UTC echo "\n"; echo CarbonTimeZone::create(); // UTC
  3. You can filter by dates like so: $events = $page->children('limit=50, date<=today, sort=-date'); Also check this thread to see more details: date_start>=today date_start>=1365436783 date_start>=2013-04-08 date_start>=4/8/2013 date_start>=8.4.2013 date_start>="April 8, 2013"
  4. Here's my version: <?php // Cache all topics $template = $templates->get("topics"); $topics_children = $cache->get("all_topics", $template, function($pages) { return $pages->get("/topics/")->children(); }); //Topic1|Topic2 $search_topics = explode("|", $input->whitelist->topic); //Get Topics from cache foreach($topics_children as $topic) { $checked = (is_array($search_topics) && in_array($topic->title, $search_topics)) ? ' checked ' : ''; echo "<label for='{$topic->title}'><input type='checkbox' name='topic[]' $checked value='{$topic->title}' id='{$topic->title}' /> {$topic->title}</label></br>"; } //On my search template if($input->get('topic')) { $value = $sanitizer->selectorValue($input->get('topic')); $selector .= "topics=$value, "; $input->whitelist('topic', $value); } ?>
  5. I'm happy that you found the solution πŸ™‚
  6. My bad, I misread it. Maybe this will help you:
  7. Forgot to mention that although I load more items using javascript, the query parameters are kept between the pages.
  8. Here's how I did it on a similar project. The search query: https://www.brightline.org/resources/?keywords=distributed&resource_type=Reports&topic=Blockchain&author=Blockchain+Research+Institute&submit=1 On the page: if(count($resources) > 0) { $segment = ''; if($input->urlSegment1) { $segment = $sanitizer->selectorValue($input->urlSegment1); $segment .= "/"; } echo $pagination = renderPagination($resources, $segment); } And on a _func.php (or any other file like _init.php) function renderPagination(PageArray $items, $segment = '') { if(!$items->getLimit() || $items->getTotal() <= $items->getLimit()) return ''; $next = isset($options['next']) ? $options['next'] : __('Next'); $previous = isset($options['previous']) ? $options['previous'] : __('Previous'); $page = page(); if(!$page->template->allowPageNum) { return "Pagination is not enabled for this template"; } // customize the MarkupPagerNav to output $options = array( 'numPageLinks' => 4, //4 is a good size for mobile as we're using next and prev items 'nextItemLabel' => $next, 'nextItemClass' => 'js-next', // 'previousItemLabel' => '<span><i class="uk-icon-angle-double-left"></i></span>', // 'previousItemClass' => '', // 'lastItemClass' => '', // 'currentItemClass' => 'tw-bg-orange tw-font-bold', 'separatorItemLabel' => '<span>&hellip;</span>', 'listMarkup' => "<ul id='js-pagination' class='tw-my-8 tw-justify-center tw-text-lg tw-list-reset tw-flex'>{out}</ul>", 'itemMarkup' => "<li class='{class} tw-mr-3'>{out}</li>", 'linkMarkup' => "<a href='{url}' class='tw-rounded tw-bg-white tw-px-3 tw-py-2 hover:tw-bg-orange hover:tw-text-white'>{out}</a>", 'currentLinkMarkup' => "<span class='tw-px-2 tw-py-2'>{out}</span>" ); $pager = modules('MarkupPagerNav'); $pager->setBaseUrl($page->url.$segment); return $pager->render($items, $options); }
  9. One thing is to load the search result in memory on PHP side on a $pages->find, another is render the HTML in the browser. There's no way to render a HTML node tree of that size without some solutions like image lazy loading through a script, especially on mobile browsers. Nowadays it's partially supported natively, but for most cases you need to rely on Javascript. Google Images loads more images as you scroll the page, you can see this better if you slow down your connection using Chrome Devtools, for instance.
  10. In the near future I plan to study on using Teppo's module to build an index directly to a Meilisearch instance running on the same server. I used it on a recent Laravel project and, although I only scratched the surface of its capabilities, the partial match and typo toleration is worth a try IMHO. Also it was a breeze configuring it.
  11. There's also this cool module by @teppo that let you create a search index to speed up things immensely on some cases. https://modules.processwire.com/modules/search-engine/
  12. I am also planning to do that in the near future, I download a couple of apps and also will explore this: https://code.visualstudio.com/docs/remote/codespaces
  13. Here's an example of a basic module to store each download as a row on a separate table. I hope it can be useful somehow πŸ™‚ And here's how to call it from your template, form hook etc.: $download_counter = wire('modules')->get("ExternalDownloadCounter"); $download_counter->countDownload($page_name, $resource_file, $selected_language);
  14. Yep, that's the challenge indeed. I need to take a look at how Klaro does that, as mentioned by @gebeer.
Γ—
Γ—
  • Create New...