Jump to content

pmarki

Members
  • Posts

    26
  • Joined

  • Last visited

Posts posted by pmarki

  1. 1 hour ago, PWaddict said:

    Thanks for the quick fix. I'm trying to update the module via ProcessWireUpgrade but when I check if there is a new version it still says that the latest is the one I'm currently using the 1.1.2. Any idea why it doesn't show me the 1.1.3 version to update? 

    PW refreshes versions once a day, so you have to wait or update manually.

    • Like 1
  2. 16 hours ago, biber said:

    What I have now is a counter that increases when a guest visits the first page of his session. It could be interesting to

    1. merge the counters of the single pages to get the number of all visits.

    2. count the visit of the second, third ... page within the session.

    To be honest I had the same issue and decided to count visits on other pages but home, because I was more interested in how many people visit a new post in a week than how many visits I have so far. In this case I didn't use visit_counter_flag at all assuming that visitors don't come back to posts. So in this line:

    if($session->get('visit_counter_flag') === 0 && !$user->isSuperuser())...

    I only check if not superuser, that's why there was an error with ===, sorry about that.

    As it was sad here: processwire.com/talk/topic/12191-make-visit-counter-code-count-once-per-session/ there are better ways for statistics, our way is suitable for estimates only.

    If you would like to count visits per page and on a home page you can increase siteviews  if it's not a home page and event if visit_counter_flag  is not 0.

  3. I have it in a site/ready.php (if you don't have this file just create one)

    function bot_detected() {
    
      if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
        return TRUE;
      } else {
        return FALSE;
      }
    }
    
    if($session->get('visit_counter_flag') === 0 && !$user->isSuperuser()) {
    	if (bot_detected()) return;
        /* if the user is NOT logged in and not counted */
    
        /* turn of output formating so PW do not give an error when we change the value */
        $page->of(false);
    
        /* save the visitor_counter field */
        $page->set('visitCounter', ($page->visitCounter ?? 0) + 1);
        $page->save('visitCounter', array('quiet' => true, 'uncacheAll' => false, 'resetTrackChanges' => false));
        /* turn on output formating so PW work as it should */
        $page->of(true);
        
        /* set a visit counter flag to 1 so next load do not count */
        $session->set('visit_counter_flag', 1);
    }

    As a extra bonus this script exludes bots from statistics.

     

    • Like 4
  4. I thought about it as well. If you created a foot template and a foot.php file is included in a _main.php it does't mean that fields from this template will be accessible. You should add visit_counter to page-currently-being-rendered template.

    Btw.: I use something like this for the same purpose:

    $page->save('visitCounter', array('quiet' => true, 'uncacheAll' => false, 'resetTrackChanges' => false));

    Otherwise on all pages the modified user will be quest.

    • Like 2
  5. 2 hours ago, tpr said:

    How about removing the "pencil" icon from the asm items and open the edit modal on click?

    I think I'll leave it as is. It's a good indicator for newcomers and obvious for advanced.

     

    38 minutes ago, tpr said:

    Setting line 42 to this fixes it:

    Thanks, fixed

  6. I have reorganize module settings, it uses JSON and ASM Select for fields, now it's possible to reorder settings, add, delete and so on. The only drawback is that it's not compatible with previous version. If you want to update, you will lose all entered  settings.

    • Like 1
  7. 16 hours ago, KarlvonKarton said:

    This module redirects to the custom page when page/  , But it does not redirect when page/list/
    In the latter situation the pagetree is still visible.

    What can I do to prevent that?

    Is this a good practice to prevent it?
     

    
    public function viewable($event) {
    		$page = $event->object; 
    		$user = $this->user;  
    		if ( ($page->id == 3 || $page->id == 8) && $user->hasRole('custom-role')) {
    			$event->return = false;
    		}
    	}

    ps: thus with the extra added $page->id = 8

    you can check its path:

    if ($page->path == '/admin-page-name/page/list/') $event->return = false ;

  8. On 12.09.2016 at 8:53 AM, tpr said:

    Looks like it works fine with AOS, thanks!

    There was 2 light lines in the header that I just removed from AOS.

    FYI, If you need to style something differently for AOS, you can use 'html.aos {...}' in your CSS (or 'html:not(.aos) {...}').

    I just didn't want to override to much AOS css, that's why those 2 light lines were left untouched.

     

    On 12.09.2016 at 8:58 AM, tpr said:

    Just spotted that this line shouldn't have a comma.

    Thanks, fixed.

  9. There is a new version of the module, as tpr suggested all features are optional. Now works in AdminOnSteroids, but:

    - you can have turned on sticky header in only one module (though in AdminOnSteroids must have sticky compact),
    - if you have AOS header "Show host name" doesn't work
    - if you have DarkAdmin header "Always show search field" should be disabled and "Place header button next to title" should be enabled
    - probably other small glitches, but overall should be usable.

     

    • Like 1
  10. 4 hours ago, tpr said:

    I'm using my MultiValueTextformatter module for such things, added to the Home page. Works fine, though it's for the developer only, not for the client because he could easily mess things up. If I use an InputfieldTextaraeaLanguage then it's multilanguage too - btw, is your module multilang capable?

    I have another idea in mind for such a module that would heavily depend on JavaScript (namely Vue.js). It would be responsible for the UI, all settings would be saved as one JSON.

    Yes, I used to use MultiValueTextformatter for this and had the same worries. Just modified it a little to have 'some kind of multilanguage support', not as convenient as built in pw, but better than nothing :rolleyes:

    • Like 1
  11. This module provides a solution for keeping various site settings in one place (titles, slogans, api keys, emails, addresses, etc.).

    Features

    - Admin can create unlimited number of settings
    - Settings can be grouped
    - Admin can set setting label, notes, property name, field width and type
    - Settings can be of type text, checkbox, radios, select, email, url, integer

    How to use

    In module configuration create as many settings as needed. Customize their label, type, width and provide a name you want to use in a template files (property name). After that admin can set those  settings on "General Settings" page in "Setup" section.
    Every time you wish to output eg. site name you can use $settings->site_name or wire('settings')->site_name or $settings->option2 to get value of 'Check it' as seen on the first screenshot. (Checked checkbox returns 1).
    You can change global name ($settings) to something else in module configuration.

    To get basic markup with all settings and their values use $settings->render(), usefull to check returning values (esp. select/radios - their values are sanitized as page names).

    Current limitation:
    -no way to change order of settings,
    -new settings can only be added at the bottom.

    Multilanguage

    To make fields multilanguage aware create a field with a same property name with '_languageName' appended. Example: Your site has two languages: default and french, create site_title and site_title_french fields. Put in a template $settings->site_title. If a user has set french language, this module output site_title_french, otherwise site_title. Please notice that render() function is not language aware.

    https://github.com/pmarki/ProcessGeneralSettings

    Screenshot_20160920_110011.pngScreenshot_20160830_180429.png

    • Like 11
  12. Thank you for your feedback, I'm really glad seeing someone else interested. My idea was to make most used features easily accessible that's why Pages and Settings are always open, modules configurations always closed and Access is opened on hover (Mike Rockett 2, 3, 4.). With such a configuration you can with one click only check a name of a field or go to template settings still having less frequently used sections collapsed. So it's not a bug, it's a feature :P

    I have never used system notification, so will check it.

    I'll try to make some features optional in next release as tpr suggested.

    UPDATE: Just uploaded small fixes (notification bell, shadow, sidebar scrollbar, header height aligned to sidebar items)

    • Like 2
×
×
  • Create New...