Jump to content

Sergio

Members
  • Posts

    530
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Sergio

  1. We upgraded a big multi language site to 3.0.200 and to PHP 8* + MySQL 8 a couple of days ago, several thousands pages, lots of templates and fields (120MB DB).

    The upgrade went fine, and the site is running super fast! I didn't measure with tools, but just by reaching the URLs of some complex pages and you can see it loading waaay faster. The client could not be happier.  ?

    Fantastic job, Ryan and the other contributors! 

    Thank you,

    Sergio

    ---

    * I used RectorPHP to help upgrading my custom modules, which was nice. 

    • Like 10
    • Thanks 3
  2. Great tips from Diogo and I'd like to suggest Hugo (https://gohugo.io/) as a great SSG, specially if you want to explore alternatives to javascript-based ones for two basic reasons:

    1. You don't want to mess with a lot of javascript dependencies fatigue, specially as you go back to edit the project in a few months/years, and things start to break when you try to run the project.

    2. The project will have 100s or 1000s of pages and you want to generate it as fast as possible. 

    • Like 2
  3. 2 hours ago, daniel_puehringer said:

    Question: is it possible to have one global field in which changes the content for the footer of all pages?

    Hi Daniel! 

    It sure is. A simple way to do it is to have the field on only ONE page, like the homepage or a "settings" page and get this page's field content in your footer template. 

    For instance, if you have this field on your homepage, called "footer_text", you can get it this way:

    // On your footer.php file
    
    //Get the homepage reference
    $homepage = $pages->get('/');
    
    // Let's say your field is called "footer_text"
    echo $homepage->footer_text;
    
    
    // Docs: https://processwire.com/api/ref/pages/get/

     

    • Like 2
  4. 14 minutes ago, PWaddict said:

    It doesn't work. The title field is still empty.

    Your code seems to be missing one line:

    $wire->addHookAfter("Pages::saveReady", function(HookEvent $event) {
    
      $page = $event->object; //this line
    
      if($page->template->name != 'mytemplate') return;
    
      $defaultLang = wire("languages")->get("default");
    
      $page->title->setLanguageValue($defaultLang, "New Value");
    
    });

     

  5. 1 hour ago, JeevanisM said:

    Any suggestion for this ? 

    25,000 per hour/day/week? It all depends.

    From what you described about the app, even 25k users a day should be fine to start with a VPS with 2GB of RAM. If its usage increase a lot you can move the database to another VPS on its own AND/OR increase the VPS CPU and RAM resources very quick.  

    My advice is to keep things simple and not try to over-engineer the application performance from the start. But if you feel "adventurous" ? or think that the project will have this many users right away on day one (which I doubt) you can start with a "serverless" approach where the infrastructure is scaled on-demand, using https://vapor.laravel.com/ and you don't have to worry. There's a course about this approach that is very interesting: https://serverlesslaravelcourse.com/

    • Like 2
    • Thanks 1
  6. Although doable, I'd only recommend a system like this to be implemented using ProcessWire if the rest of the project must (or already is) be highly coupled with PW and it doesn't make sense to decouple it for whatever reason. Otherwise I'd recommend you to implement it using another framework. PW shines in the content management part, and I love it, but it may present you with some limitations in its developer-experience department when you need to implement some business logic that relies heavily on integration of payment systems, user data input, generation of reports and especially tests. There's also a myriad of similar systems like this already implemented that you can use as a base, like this one https://github.com/LaravelDaily/Laravel-Test-Result-PDF (demo: https://www.youtube.com/watch?v=GmLFHGud7I8). 

    • Like 4
  7. 18 hours ago, schwarzdesign said:

    Maybe you have an older version of the font installed on your Computer?

    Good call. I checked and I had Rubik installed so I disabled it but the problem remained, maybe I need to restart the computer to work, but I can't do it right now. But I also checked again the website and the only problem appears to be on 300 font-weight. 400 or more are fine ( I changed it to 400 on the Body as a test, screenshot attached). 

    image.png.7c55837b5610ddf21521f61a03b4c408.png

    • Thanks 1
  8. 1 hour ago, kongondo said:

    Hi @Sergio, just for clarity, Carbon will work with what you hand to it, right? i.e., it has no way of knowing a user's (browser client) TZ.

    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!

  9. 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

     

  10. 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" 

     

    • Like 2
  11. 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); 
    }
    ?>

     

    • Like 1
    • Thanks 1
  12. 1 hour ago, 3fingers said:

    Thanks @Sergio but I don't think my problem is related to pagination, infact it works correctly on my side.
    I think it's rather something to do with whitelist on multiple checkbox (eg. forme_options[] ) which I cannot get it works. Also take a look at my url in my last post above:

    
    %5B%5D // I think it's [] encoded, but then it get lost on subsequent pages

    My bad, I misread it. 

    Maybe this will help you:

     

    • Like 1
  13. 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);
    }

     

×
×
  • Create New...