Jump to content

Matzn

Members
  • Posts

    55
  • Joined

  • Last visited

Posts posted by Matzn

  1. I found some "special" on ProcessLogin.js

    #login_start is setting by php on server and ts is build by javascript on client. If the time on the server is much older than the time on the client, for example more 300 seconds, you get endless reloading. 

    	var startTime = parseInt($('#login_start').val()); // GMT/UTC
    	var maxSeconds = 300; // max age for login form before refreshing it (300=5min)
    	
    	// force refresh of login form if 5 minutes go by without activity
    	var watchTime = function() {
    		var ts = Math.floor(new Date().getTime() / 1000);
    		var elapsedSeconds = ts - startTime;
    		
    		if(elapsedSeconds > maxSeconds) {
    			window.location.href = './?r=' + ts;
    		}
    	};

     

    • Like 1
  2. Thank you for your description. You're right if some syntax isn't 100% correct. But what I mean is the thing is that I can't call a parent function from a child function because the parent field value doesn't inherit.

    $m2 = $modules->get("TestModuleChild");
    print_r($m2->getField());//function will not overwrite in child class

    The function result is (note field 2)

        [field 1] => parent module property 1
        [field 2] => default field 2

    I would have expected (note field 2), because i have input it on parent module (screenshot Parent Module)

    [field 1] => parent module property 1
    [field 2] => Parent Module field 2

     

    So I'm wondering if I can extend processwire class like a php class at all. At least not as a module extension.

  3. @Zeka @ryan

    I tested again and found that the "ModuleConfigInputfields" are not inherited. This means that the parent methods not can be call from child class, if "ModuleConfigInputfields" are used in parent class. To get "ModuleConfigInputfields" for inherited modul/class must get first the module like: wire()->modules->get('modulname);

    Here's the proof:

    <?php
    //template file
    namespace ProcessWire;
    
    $m1= $modules->get("TestModule");
    print_r($m1->getField());
    
    $m2 = $modules->get("TestModuleChild");
    print_r($m2->getField());
    //output
    Array
    (
        [field 1] => parent module property 1
        [field 2] => Parent Module field 2
    )
    Array
    (
        [field 1] => parent module property 1
        [field 2] => default field 2
    )

     

    parent_module.png

    child_module.png

    TestModule.module TestModuleChild.module

  4. @ryan No, i m using other class names. My IDE helps me for wrong syntax.

    It was not possible for me to get the properties api_user and api_key in a child class. No matter which variant I tried (intern or extern modul config im testing). The values were not available in the children's class. Why, i don't know, maybe i do some ? 

  5. Maybe I also have mistakes in thinking and a processwire class can't extend like php. Is that so?

    I get the parent methodes and properties like:

    class Child extends Parent implements Module
    {
    	
    	public function myMethode()
    	{
    		$myParentModul = wire('modules')->get('Parent');
    		$token = $myParentModul->test();
    	}
    }

     

  6. @Zeka @ryan

    Hui, now i am confused... Yes, I want a parent/child class relationship like php class extend.

    I'm writing modules as on this page discribed: ProcessWire 2.5.5 – New module configuration

    The modul file(excerpt)

    //file: parent.modul
    class Parent extends WireData implements Module
    {
    
    	public static function getModuleInfo()
    	{
    		return array(
    
    			'title' => 'Network Adcell',
    			'version' => 1,
    			'summary' => 'Loading Data from Affiliate Network.',
    			'singular' => true,
    			'autoload' => false,
    
    		);
    	}
    	public function getToken()
    	{
    		$data = $this->_request(
    			'user',
    			'getToken',
    			[
    				'userName' => $this->api_user,
    				'password' => $this->api_key,
    			]
    		);
    
    		return $data->data->token;
    	}
    
    	public function test()
    	{
    		$data = [
    				'userName' => $this->api_user,
    				'password' => $this->api_key,
    			];
    
    		return $data;
    	}
    
    }

    The parent modul config file:

    //file: ParentConfig.php
    
    class ParentConfig extends ModuleConfig
    {
    
    	public function getInputfields()
    	{
    		$inputfields = parent::getInputfields();
    
    		$f = $this->modules->get('InputfieldText');
    		$f->attr('name', 'api_user');
    		$f->label = 'API User';
    		$f->required = true;
    		$inputfields->add($f);
    
    		$f = $this->modules->get('InputfieldText');
    		$f->attr('name', 'api_key');
    		$f->label = 'API Key';
    		$f->notes = 'Der API Key muss im Adcell Backend erstellt werden.';
    		$f->required = true;
    		$inputfields->add($f);
    
    		return $inputfields;
    	}
    }

     

    The parent modul is an old modul that i can't/wan't thouch. So i think i extend the parent class with new methods.

    The child modul (excerpt)

    class Child extends Parent implements Module
    {
    	public static function getModuleInfo()
    	{
    		return array(
    			'title' => 'Import Adcell programs',
    			'version' => 1,
    			'summary' => 'Import new joined programs and offers.',
    			'singular' => true,
    			'autoload' => false,
    			'requires' => 'Parent modul'
    
    		);
    	}
    
    	public function addProgram()
    	{
    
    		/* this will get:
            * array(2) {
            *  ["userName"]=>NULL
            *  ["password"]=>NULL
            * }
    		*/
    		$token = $this->test();
    
    		//some further code
    
    	}
    	
    }

     

    In child modul if call "$this->test();" get null, because (i think) the ParentConfig will not extend/call what ever. Also is $this->api_user=null and $this->api_key=null. A simple solution is to add a constant/property to parent modul, but i wan't touch this file.

    I hope we don't talk past each other?

  7. Hi,

    how I can access parent modules config fields? It is also not possible to use the parent methods include this fields.

    Example: I need field "api_user" in Child class.

    class Parent extends WireData implements Module
    {
    	public function getApiUser()
    	{
    		return $this->api_user;
    	}
    
    }
    class ParentConfig extends ModuleConfig
    {
    
    	public function getInputfields()
    	{
    		$inputfields = parent::getInputfields();
    
    		$f = $this->modules->get('InputfieldText');
    		$f->attr('name', 'api_user');
    		$f->label = 'API User';
    		$f->required = true;
    		$inputfields->add($f);
    
    		return $inputfields;
    	}
    }
    
    
    class Child extends Parent implements Module
    {
    	//null
    	$apiUser = $this->api_user;
    	//null
    	$apiUser = $this->getApiUser();
    	
    }

     

  8. Oh yes, it´s a old post. But now i have the same issue and find the same results at a multilingual site (post before).

    What i can do to prevent a redirect?

    Pass the correct url or i can set some template parameters? 

    Greetings

     

    edit

    This setting causes an endless redirection, if get the url by an other language. But one redirect is still running, eg. for france

    https//domain.com/ajaxpage => https//domain.com/fr/ajaxpage and there lost the post parameters.

    image.thumb.png.f3a19fc36ca5ec9e9f39f858f730e121.png

  9. The error message as mentioned above:

    Quote

    Error: Exception: SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. (in wire/core/Fieldtype.php line 1333)

    Now change the affected field to ROW_FORMAT=DYNAMIC like:

    ALTER TABLE `mytable`  ROW_FORMAT=DYNAMIC;

    In my case for field productDescription:

    ALTER TABLE `field_productDescription`  ROW_FORMAT=DYNAMIC;

     

  10. Hi @bernhard. I've tested all field settings, but nothing works. I want html to save, because i think i can. ?

    Edit:
    But now i found something by save directly this field (i am surprised why get this exception not by saving the page - maybe it´s different by saving from template or module):

    $this->page->save("productDescription");

    I get a SQL error by can't save this table: it was too big or similar message (can't remember on the exact message). This means, the data to save is too big for this table ( field_productDescription). So i've set the table to ROW_FORMAT=DYNAMIC. This is a general problem and know it from other multilanguage sites - but forget. ?

  11. I've tested alternate syntax with "setLanguageValue" . Get the same result. But to sanitized the input from field "productDescription" works:

    $this->page->productDescription = $this->sanitizer->textarea($this->productTypeData->description);

    Are there bad signs that cause this to skip? As I said, only at the last language (danish). If i change the language order, it's always the last language.

    Unbenannt.PNG

  12. I want to save HTML Code in multilanguage field (productDescription -> texarea, unknow text) from module. But for the last language is nothing written in this field. It only works when I sanitized the string.

     

           
    
            foreach ($this->languages as $language) {
    
                $this->user->language = $language;
    
                //get spreadshit product data
                $this->productTypeData = $this->getProduct($language);
               
    
     			$this->page->of(false);
                //fields by language
                $this->page->title = $this->productTypeData->name;
                $this->page->fit = $this->productTypeData->sizeFitHint;
                $this->page->shortDescription = $this->productTypeData->shortDescription;
                $this->page->productDescription = $this->productTypeData->description; //include html tags
    
                $this->page->save();
    
            }
    
    		

     

  13. Hi all,

    how i can get total, start, limit etc from page object?

    $res = $pages->find("template=basic, limit=20");

     

    Result from page 2:

    ProcessWire\PageArray Object
    (
        [count] => 20
        [total] => 95
        [start] => 20
        [limit] => 20
        [pager] => 21 bis 40 von 95
        [items] => Array
            (
                [Page:0] => Array
                    (
                        [id] => 17212

     

    • Like 1
  14. @Macrura I have tested something. If add the date field to page or repeater page it works, but not to a fieldsetpage:

    echo "\nFieldsetPage:\n";
    echo $page->Check->ratingDate;
    echo "\n";
    echo $page->Check->getUnformatted("ratingDate");
    echo "\nPage:\n";
    echo $page->ratingDate;
    echo "\n";
    echo $page->getUnformatted("ratingDate");
    echo "\nRepeaterPage:\n";
    echo $page->About->businessProvider->first()->ratingDate;
    echo "\n";
    echo $page->About->businessProvider->first()->getUnformatted("ratingDate");

    Live Result:

    FieldsetPage:
    19.05.2021
    19.05.2021
    Page:
    19.05.2021
    1621375200
    RepeaterPage:
    19.05.2021
    1621429619

    It's a bug or i can set somthing?

  15. @wbmnfktr ic know this postes, but no way to get the unix timestamp by

    $page->getUnformatted('yourDateField');

    I also used it in several projects, but now the output must be set for date field to none. So i use this date field only as

    $page->yourDateField;

    I also don't understand why one field is save as unix and the other not (same settings).

  16. Hi,

    i have two date fields. One stores in unix timestamp (ratingDate) the other as a normal date (googlePageSpeedDate). Both have the same settings! How can I influence the saving?

    The strange thing is that I can't get the unix timestamp by (Check is the FieldsetPage) $page->Check->getUnformatted('googlePageSpeedDate');

    ProcessWire\FieldsetPage Object
    (
        [id] => 9932
        [name] => for-page-1072
        [parent] => /admin_panel_page/repeaters/for-field-389/
        [template] => repeater_Check
        [name1067] => 
        [status1067] => 1
        [googlePageSpeedDate] => 2021-05-17 00:00:00
        [data] => Array
            (
                [name1067] => 
                [status1067] => 1
                [googlePageSpeedDate] => 2021-05-17 00:00:00
            )
    
    )
    ProcessWire\RepeaterPage Object
    (
        [id] => 1137
        [name] => 1618998033-3988-1
        [parent] => /admin_panel_page/repeaters/for-field-312/for-page-1075/
        [template] => repeater_businessProvider
        [name1067] => 
        [status1067] => 1
        [isSocialMedia] => 0
        [businessProviderPage] => (Page) 1132
        [rating] => 4,6
        [ratingUsers] => 10
        [ratingDate] => 1621240175
        [urlTo] => https://maps.google.com/?cid=11132489695980159614
        [reviewUrl] => 
        [data] => Array
            (
                [name1067] => 
                [status1067] => 1
                [isSocialMedia] => 0
                [businessProviderPage] => ProcessWire\Page Object

     

  17. It´s a old post, but i'm looking for this same problems. Hope, helps you, too.

    1. It must be noted that if "When output formatting is off the value of an image/files field is always a WireArray" found here
    2. to save works only $page->save(image/files field)

    Example for a custom field "counter" :

    $page->of(false);
    $file = $page->csvFiles->first();
    $file->counter = "your content here";
    $page->save('csvFiles');

    Actually easy.

  18. Quote

    What other changes did you make already?

    Nothing special. Only add new fields to template and somthing in template output.

    Quote

    And another question... how did you change the default language to german? Just by removing/changing page name defaults from the homepage or are you using any hooks already?

    No. That's the weird thing. I don't touch hooks or other settings. Language only change default backend settings. It's an (almost) new installation.

    I think slowly it is due to php or something on the server. I've an other similar project. I will to compare this booth.

×
×
  • Create New...