Jump to content

DV-JF

Members
  • Posts

    318
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by DV-JF

  1. Hi,

    maybe I've found a bug, but there's a behavior I can't explain:

    I'm trying to hook into Pages::saveReady with following code example: https://processwire-recipes.com/recipes/extending-page-save-process/

    <?php
    
    /**
     * Hook the saving of pages to add own processes.
     * 
     * ProcessWire 2.x 
     * Copyright (C) 2014 by Ryan Cramer 
     * Licensed under GNU/GPL v2, see LICENSE.TXT
     * 
     * http://processwire.com
     *
     */
    
    class HookAfterPagesSave extends WireData implements Module {
    
        public static function getModuleInfo() {
    
            return array(
                'title' => 'HookAfterPageSave', 
                'version' => 1, 
                'summary' => 'Hook the saving of pages to add own processes.',
                'singular' => true, // Limit the module to a single instance
                'autoload' => true, // Load the module with every call to ProcessWire 
                );
        }
    
        public function init() {
            // init() is called when the module is loaded.
            // saveReady is a hook after processing the previous changes of the page,
            // but just before those changes are saved to the database.
            // It's called for each page that's being saved, no matter if it's in
            // the backend or in your templates via the api.
            $this->addHookAfter('Pages::saveReady', $this, 'afterSaveReady'); 
        }

    In the afterSaveReady() function I'm trying to get the language property of the user who saved that page, but instead of returning the correct user language the default language is always returned.

    <?
    public function afterSaveReady($event) {
      $userLanguage = $this->user->language;
      bd($userLanguage);
      $this->message("User Language: ".$userLanguage);
    };

    Here's the output and a test with the console of TracyDebugger

    1288157441_2019-10-3111_56_35.jpg.0f89693831a51f2df263d727aa086c46.jpg

    Any ideas? Should I open a ticket here: https://github.com/processwire/processwire-issues/issues ?

    Many greets!

    • Like 1
  2. On 10/29/2019 at 11:06 PM, d'Hinnisdaël said:

    Is the default language tab still initially active after you increase its sort value? Or does PW always focus/activate the first visible tab?

    Which tab is initially activated depends on the chosen user language. 

    See \wire\modules\LanguageSupport\LanguageTabs.module line 69:

    // determine the index of the tab for the user's language	
      $activeTab = 0;
      foreach($this->languages as $index => $lang) {
      if($lang->id == $language->id) $activeTab = $index;
    }

     

    • Like 1
  3. Hey girls and guys,

    I'll want to open this thread in order to discuss a main problem I've run into with following setup:
     

    I'm maintaining a site where different URLs are directed to the same folder. In site/ready.php the $user->language is set based on the $config->httpHost

    <?php /* Set language based on the domain and user is not logged in */  
    
    /* Slovenian */   
    if(
        $config->httpHost == "www.domain.si" || 
        $config->httpHost == "domain.si" || 
        $config->httpHost == "domain.si.local") {
        if (!($user->isSuperuser()))	$user->language = $languages->get('si');
    }
        
    /* German */
    elseif(
        $config->httpHost == "www.domain.at" || 
        $config->httpHost == "domain.at" || 
        $config->httpHost == "domain.at.local" ||
        $config->httpHost == "domain.ch" || 
        $config->httpHost == "www.domain.ch" || 
        $config->httpHost == "domain.de" || 
        $config->httpHost == "www.domain.de") {
        if (!($user->isSuperuser())) $user->language = $languages->get('default');
    }
    
    /* Croatian */
    elseif(
        $config->httpHost == "www.domain.hr" || 
        $config->httpHost == "domain.hr" ||
        $config->httpHost == "domain.hr.local") {
        if (!($user->isSuperuser())) $user->language = $languages->get('hr');
    }
    
    /* English */
    elseif(
        $config->httpHost == "www.domain.eu" || 
        $config->httpHost == "domain.eu" ||
        $config->httpHost == "domain.eu.local") {
        if (!($user->isSuperuser())) $user->language = $languages->get('en');
    }
    
    /* Italian */
    elseif(
        $config->httpHost == "www.domain.it" || 
        $config->httpHost == "domain.it" || 
        $config->httpHost == "domain.it.local") {
        if (!($user->isSuperuser())) $user->language = $languages->get('it');
    }

    The homepage (id=1) has following settings:

    1163626795_2019-10-2513_15_32.thumb.jpg.bb13dfb04ef00a5c497e2df66e9328d7.jpg

    As you can see German (Deutsch) is set as default language. Everything is working nice and fine and I'm really happy with this kind of setup but now there are some new requirements, which causes me quite a headache :

    1. I've to add some pages only in one or two languages (they should not be present in German)
    2. I've to create some editor roles that are allowed to only edit (can be done with https://processwire.com/docs/user-access/permissions/#multi-language-page-edit-permissions) & add pages to their specific language.

    What I've found out so far:

    1. The default language can't be disabled and must always be present (though this would be in my eyes the easiest solution)
    2. Creating my own "language select field" - example here: won't work in this case because I've to rely on the native languages in order to setup the right permissions for editors.
    3. There seems to be some solutionsbut I think these won't match for me because I've to think about handling editors and permissions, too.

    After searching and searching, scratching my head and searching and searching again, the only possibility that comes to my mind is to add another language for German and assign this language to the specific URL's instead of the default language.

    The advantages with this solution for me:

    • I could activate or deactivate any language on any page
    • Editors which are allowed to add pages can get the permission page-edit-lang-default without affecting the German pages.

    The disadvantages:

    • All multi-language-fields will have an empty tab for the default language - this may irritate editors a lot
    • Seems to me like a lot of work to do because I've to copy the language field nearly for 1000 pages/repeaters (maybe I'll find an SQL query)

    My questions:

    1. How would you handle this task?
    2. Could my setup be optimized in a completely different way?
    3. If I go for my solution (adding another language for German) would it be possible to hide the language tab for default language in any way? 

    If some points aren't clear enough please don't hesitate to ask.

    Many greets...

  4. Hi all...

    after looking into the I've recognized some errors caused by this module.

    Error: Exception: Login not attempted due to overflow. Please wait at least 5 seconds before attempting another login. (in /***/public_html/wire/modules/Session/SessionLoginThrottle/SessionLoginThrottle.module line 150)
    
    Error: Exception: Login not attempted due to overflow. Please wait at least 20 seconds before attempting another login. (in /***/public_html/wire/modules/Session/SessionLoginThrottle/SessionLoginThrottle.module line 150)
    
    Error: Exception: This request was aborted because it appears to be forged. (in /***/public_html/wire/core/SessionCSRF.php line 191)

    Is there a way to output these errors in a user friendly way, without throwing an "Internal Server Error" on the Frontpage (see attached video)?

    Many greets!

  5. On 9/28/2018 at 3:09 PM, DonPachi said:

    I appear to have it figured out, the registration form does not like Page Reference fields. It will accept the registration and send the confirmation code, however will always fail if the original registration form contained a page reference. Shame as my site relies on it quite heavily for the initial registration, so I will look into whether there's a workaround.

    I'd run into the same issue. Everything worked well, but then I've added a PageReferenceField to the user template.  Since then I can't complete the register process.

    Unable to complete confirmation, please re-register and try again

    1883670657_2019-02-0108_24_42.png.ee527be251fdfa4efdc01165990ecc07.png

    @Dadswell96 Did you find a workround?


    Many greets!

  6. Hi

    after updating to PW 3.0.119 I get an error-message everytime I'm visiting the page tree.

    Server logfile:

    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 497, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Notice: Trying to get property of non-object in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/				Apache-Fehler
    2018-12-13 11:51:12	Warning	x.x.x.x		mod_fcgid: stderr: PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/xxx/wire/core/Templates.php on line 498, referer: http://example.net/manager/setup/template/
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 497
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 498
    Warning: in_array() expects parameter 2 to be array, null given in /var/www/vhosts/xxx/wire/core/Templates.php on line 498
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 497
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 498
    Warning: in_array() expects parameter 2 to be array, null given in /var/www/vhosts/xxx/wire/core/Templates.php on line 498
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 497
    Notice: Trying to get property of non-object in /var/www/vhosts/xxx/wire/core/Templates.php on line 498
    Warning: in_array() expects parameter 2 to be array, null given in /var/www/vhosts/xxx/wire/core/Templates.php on line 498

    PHP Vers. 7.0.33

     

    Any ideas?

  7. Hi,

    is it possible to deactivate the default language. I've setup a multi-language-site (default=de / en / si / hr / ru ) with a blog system. Some of the news articles will be translated to all languages, some will be only available in specific languages. Therefore I've used the build in function to activate or deactivate the pages under the settings tab.

    Everything's working fine but now I need to not dispay an article in default=de language? How would you solve this problem?

    Many greets...

  8. 3 hours ago, louisstephens said:

    are you using the Profields Page Table module?

    Yes I'm using this one. 
     

    3 hours ago, louisstephens said:

    simply add "template" to the list of "Table fields to display in admin"

    Yeah I've tried this, but when I do so, the template name is displayed, which doesn't corresponded to the buttons displayed below. This may be very confusing to some editors. Have a look at the screenshot.

    2018-03-08 18_23_59.jpg

    To be clear: I want the label to be shown, not the name.

  9. Hi,

    after searching for nearly an hour, I've found nothing suitable:

    Is it possible to display the name / label of the template in the table-view used for a specific page?

    $template->name
    template->name
    template.name
    $template->label
    template->label
    template.label

    None of above does the job ;(

    The reason I'm asking: I'm using pagtables for a small layoutsystem and want to display also the template name of the page in the table.

    Many greets!

  10. Hi,

    I figured out a strange problem and don't know where to search for the error:

    I'm trying to include Processwire into an old website project in order to use PW for a little news-system . Therefore I'm using this code.

    <?php namespace ProcessWire;
    
    /*Include ProcessWire f. News */
    include $_SERVER['DOCUMENT_ROOT'].("/cms/index.php"); 
    
    /* Set news variable to get news from PW */
    $news = wire('pages')->find('template=news-page');?>

    Now I'm able to loop through the news and display them as I want to be.

    <?php /* Section - Aktuelles */
    
    if(count($news)) { ?>
    
    <div id="aktuelles" class="section-wrapper section-std-padding container activateMenu">
    
      <h2 class="sectionhead">Aktuelles</h2>
    
      <?php foreach ($news as $n) { ?>
    
      <div class="box big-image">
        <div class="two-text-columns">
          <div>
            <a href="<?php echo ("/cms" .$n->sing_img->url .$n->sing_img);?>" class="img-popup"><img src="<?php echo ("/cms" .$n->sing_img->url .$n->sing_img);?>" class="left" alt="<?php echo $n->sing_img->description;?>" title="<?php echo $n->sing_img->description;?>" style="width: 100%;"></a>
          </div>
    
          <div>
            <h2><?php echo $n->title;?></h2>
            <?php echo $n->body;?>
          </div>
        </div>
      </div>
    
      <?php }; ?>
    
    </div>
    
    <?php }; ?>

     

    These are the settings for the image field $sing_img

    5a79a5cb38e2c_2018-02-0613_54_16-Feldbearbeiten_sing_img.thumb.jpg.0b5a9bfd16f624b2dd29df65d5b80945.jpg

    And here's the strange thing happening when I try to echo the image:

    $n->sing_img->url 			= 	/cms/site/assets/files/1019/
    $n->sing_img				= 	filename.jpg
    
    $n->sing_img->size(200,200)	=	INTERNAL SERVER ERROR
    
    Fehler: Uncaught ProcessWire\WireException: Method Pageimages::size does not exist or is not callable in this context in /.../cms/wire/core/Wire.php:519
    Stack trace:
    #0 /.../cms/wire/core/WireArray.php(2212): ProcessWire\Wire->___callUnknown('size', Array)
    #1 .../cms/wire/core/Wire.php(386): ProcessWire\WireArray->___callUnknown('size', Array)
    #2 /.../cms/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___callUnknown', Array)
    #3 /.../cms/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pageimages), 'callUnknown', Array)
    #4 /.../cms/wire/core/Wire.php(445): ProcessWire\Wire->__call('callUnknown', Array)
    #5 /.../index.php(120): ProcessWire\Wire->__call('size', Array)
    #6 {main}
    thro (Zeile 519 in h.../cms/wire/core/Wire.php) 

    I've no idea why this is happening, perhaps someone of you can give me a hint!

    Many greets, Jens alias DV-JF

  11. Hi,

    I've searched for a long time, but could not find an answer:

    We relaunched a old website with a URL structure like that:

    http://www.example.com/?main=notice	
    http://www.example.com/?main=contact	
    http://www.example.com/?main=film	
    http://www.example.com/?main=references	
    http://www.example.com/?main=products&sub=sunb

     Is it possible to redirect this old links via Jumplinks? I tiedy to define "?main=notice" as source but this don't work - I get the homepage with the original parameter attached ;-(.

    Can you please give me a hint, many greets, Jens alias DV-JF

  12. Hi,

    I switched my site to https and now I can't get AIOM to running. Here are the errors I'm getting:

    Mixed Content: The page at 'https://****/' was loaded over HTTPS, but requested an insecure stylesheet 'warning: A non-numeric value encountered in /mnt/****/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713/work/roltek/site/assets/aiom/css_b863322778056fb524ea6127cc06763c_dev.css?no-cache=1503581072'. This request has been blocked; the content must be served over HTTPS.
    (index):1 Mixed Content: The page at 'https://****/' was loaded over HTTPS, but requested an insecure script 'warning: A non-numeric value encountered in /mnt/****/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713/work/roltek/site/assets/aiom/js_656d424f993dafdaf7bd972288171ab2_dev.js?no-cache=1503581072'. This request has been blocked; the content must be served over HTTPS.

    When I disable AIOM everything works like it should be. Any ideas?

    EDIT: 

    In order to debug this error I generated a subdomain without HTTPS encription. Now I get the following error:

    Warning: A non-numeric value encountered in /***/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module on line 713
    /site/assets/aiom/js_656d424f993dafdaf7bd972288171ab2_dev.js?no-cache=1503583266

    EDIT: 

    I've figured out, that the error only happens, when I'm using PHP Ver. 7.1. with PHP Ver. 7.0. everything works like it should be. 

     

    Many greets, Jens alias DV-JF

  13. Copy / Clone single pagetable-pages to another page

    Hi is it possible to clone / copy a pagetable-page to another "parent"-page with the same pagetable field via the backend? 

     

    Many Greets, Jens.

×
×
  • Create New...