Jump to content

Raymond Geerts

Members
  • Posts

    365
  • Joined

  • Last visited

  • Days Won

    5

Community Answers

  1. Raymond Geerts's post in How to validate a date range in the back-end? was marked as the answer   
    When using the jQuery datepicker in the backend for each Datetime field the following javascript might do the job. I have used this on front-end level, but it should work fine on back-end too.
    var setDate,     todayDate = new Date(); $('input[name=schedule_date_end]').attr('disabled', 'disabled'); $('input[name=schedule_date_start]').change(function() {     setDate = $(this).val();     if(setDate!='') {         $('input[type=text][name=schedule_date_end]').datepicker( 'option', 'minDate', setDate ).removeAttr('disabled');     }     else {         $('input[type=text][name=schedule_date_end]').datepicker( 'option', 'minDate', todayDate ).val('').attr('disabled', 'disabled');     } }); $('input[name=schedule_date_end]').change(function() {     setDate = $(this).val();     if(setDate!='') {         $('input[type=text][name=schedule_date_start]').datepicker( 'option', 'maxDate', setDate ).removeAttr('disabled');     }     else {         $('input[type=text][name=schedule_date_start]').datepicker( 'option', 'maxDate', null );     } }); To be able to use custom javascript in the back-end you could use Martijn's "Admin Custom Files" module for that.
  2. Raymond Geerts's post in page-publish permission, how about unpublish was marked as the answer   
    Solved, i found the module preventing unpublishing, namely: Custom Page Permissions
    Seems that it was installed year ago when building the website. I have no clue what the reason for it was. Anyway uninstalling this module solved the issue
  3. Raymond Geerts's post in Custom dashboard sorting MarkupAdminDataTable pages was marked as the answer   
    Solved, the parent template "EDIT PAGES" for the current users role, needed to be ticked.
    Now it works fine, sorting pages from a custom dashboard within a MarkupAdminDataTable.
  4. Raymond Geerts's post in Navigation Menu - Custom Links was marked as the answer   
    When its not of any concern that the navigation will be 'static' you could use a field of the type Page which contains a list of the pages you need to list.
    Create a new field called navigation of the type Page, make sure it can contain multiple pages and select the Homepage as parent.
    Then attach this field to the Home template.
    Next thing to do is add all the pages you want to list in the navigation and sort them the way you like.
    Then in your code you can loop trough them as follow:
    $navigation = $pages->get('/')->navigation; foreach($navigation as $item) {   // your html for the menu }
  5. Raymond Geerts's post in Missing tables? was marked as the answer   
    Sounds like the table(s) got corrupted somehow. Are they completely gone? If not you could try to run a repair over the tables.
    I'm not sure what could be the cause. Perhaps a corrupted sector on the hard drive?
  6. Raymond Geerts's post in sort after retrieving results? was marked as the answer   
    You already have the code i see. Looks like a good solution.
    So method A is the right way to do so in this case.
    When you want to retreive a subset of data for example 4 pages out of 1000 records in the database i recommend sorting on database level (like you did in your code). This will be faster since the database fields all are indexed. And it saves you from loading the 1000 records in to memory and sorting it afterwards and then limiting.
    Because if you would limit it before sorting you never will get the right results.
  7. Raymond Geerts's post in optimizing or not was marked as the answer   
    Optimizing on this level would have minor benefits that it would hardly be noticable.
    I would recommend limiting the amount of assets you load, the lesser the request to your server the faster the page will load.
    Secondly to have a lot of speed aprovement i can recommend the ProCache module that Ryan wrote.
    Altough i found a couple of things that you could change in your code:
    echo "<li><a href='{$pages->get(1026)->url}'>{$pages->get(1026)->name}</a></li>"; // I would recommend changing it so you only have one request for $page->get() $item = $pages->get(1026); echo "<li><a href='{$item->url}'>{$item->name}</a></li>"; $menu = $pages->find("template=browse, parent=1, sort=title");                                    foreach ($menu as $item) { ?>                                        <li><a href="<?php echo $item->url ;?>"><?php echo $item->title;?></a></li> // I would recommend changing it, not switch php html, and sort by name its significant faster that sorting by title $menu = $pages->find("template=browse, parent=1, sort=name");                                    foreach ($menu as $item) {                                        echo "<li><a href='{$item->url}'>{$item->title}</a></li>"; Regarding the amount of javascript files you load, you might want to compile those to one file and server that (possible minified and gzip compressed).
    There are scripts or modules that can do that on the fly (sorry, i dont have an URL at this moment).
  8. Raymond Geerts's post in ProcessWire MySQL utf8mb4 was marked as the answer   
    OK it seems to work now. I have done the following (from a already installed ProcessWire):

    - Export database
    - Modified the lines in the exported file that have
    ENGINE=MyISAM DEFAULT CHARSET=utf8; to be
    ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - Imported file in to the database
    - Created a MySQL config file (in my case /etc/my.cfg) and added the following lines
    [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci - Restarted MySQL
    - Modified the following ProcessWire files:

    /wire/config.php
    line 47: $config->dbCharset = 'utf8mb4';

    /wire/core/Database.php
    line 72: else if($config->dbSetNamesUTF8) $this->query("SET NAMES 'utf8mb4'");

    /wire/core/Fieldtype.php
    line 421: 'xtra' => 'ENGINE=MyISAM DEFAULT CHARSET=utf8mb4',

    /wire/core/WireDatabasePDO.php
    line 82: PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'",

    This seems to be working, i didnt get the MySQL PDO error anymore about the \xF0\x9F\x92\x93\xF0\x9F character

    Altough i'm not so happy to have modified the files in the wire folder, since these are core files and will be overwritten as soon as i update the wire folder by replacing the files inside. Would be nice to be able to set this value somewhere in a config file.
    Update: a recent update in the PW DEV branche includes the ability to set the charset in the configuration file.
    The issue is discussed here:
    https://github.com/ryancramerdesign/ProcessWire/issues/452
  9. Raymond Geerts's post in Sorting pages in templates with a field and page width different templates was marked as the answer   
    Are you certain the parent page it's template of "Organigramme" has children sorting set to none (or manual drag&drop) and not a date field?
    @martijn rainbows make me happy
  10. Raymond Geerts's post in how to build a mobile website with another template? was marked as the answer   
    Another approach would be to have a duplicate of your template folder where you use diffferent code inside your templates. I use this a lot for development in a live site, but its an easy solution to use it for a mobile website too.
    When your normal site is finished (or while developing) make a duplicate of the template folder and name it "templates-mobile". The goal here is to have exactly the same template files in both folders.
    Paste the following code at the bottom of the /site/config.php file and change the m.domain.ext to your needs
    if($_SERVER['HTTP_HOST'] == 'm.domain.ext') {     $config->urls->templates = '/site/templates-mobile/';     $config->paths->templates = $rootPath . $config->urls->templates; } This way when you visit your website on m.domain.ext it will use the templates out of the templates-mobile folder while it still uses the same data from the database, assets folder and the modules.
×
×
  • Create New...