Jump to content

regesh

Members
  • Posts

    65
  • Joined

  • Last visited

Posts posted by regesh

  1. Any field has visibility option (showif) that works perfect with field in current template. But i need to compare with the field in parent page template. Is it possible?
    The task is like that: I have multiselect field in parent page - it is "Page Refference" field.   And i need field in children page compare that there is some page selected in parent multiselect field for it to show in editor.

  2. On 1/12/2022 at 12:49 AM, Jan Romero said:

    Hi, yeah, repeater items are just pages, so you should be able to load them the regular way using pages()->find(). I think every repeater field creates a hidden template named after the field, so in your case it should be

    pages()->find('template=repeater_clientsubscriptions, include=all')

    You probably have to use “include=all” to bypass the permission system.

    When you have a repeater page, you can get the page it belongs to by calling $repeaterItem->getForPage(). Also, maybe check this out: https://processwire.com/blog/posts/processwire-3.0.95-core-updates/.

    Also have a look at this blog post on some new performance features: https://processwire.com/blog/posts/find-faster-and-more-efficiently

    What does this do?

     

    Thanks a lot!
    thats is just my helper custom function
     

    function pre($data,$exit = false){
    	echo '<pre>';
    	var_dump($data);
    	echo '</pre>';
    	if($exit){
    		exit();
    	}
    }


     

    • Like 1
  3. Thanks a lot!
    Yes, I realized that requests in a loop (and a selection of repeaters are requests) the decision is fundamentally wrong. Thank you for reminding me of this again. But in the morning I realized it too)
    I got one more querstion.
    Let's say I have pages with a specific template, a repeater is attached to the template. Is it possible to immediately get an array of all repeaters for the specified pages and then, having already looped through these repeaters and finding the necessary information, determine which page this repeater is attached to.

    Thanks again!)

  4. I got about 2 thousand records with repeater field for each. And i need to get some result from that. Could anybody help me with how to optimize query for better performance (not 6-7 seconds as now)
    I'm executing getSubs() functions. Thanks a lot!

    <?php
    function getNextAction($clientId){
        $result = [];
        $today = new \Datetime(date('Y-m-d', time()));
        $today = $today->format("U");
        $action = wire('pages')->findOne('sort=action_start,template=action,selectedClient='.$clientId.',action_start>'.$today);
        if($action->id){
            pre($action);
            $a = $action->selectedTrainer->text1.' '.$action->selectedTrainer->text2;
            $b = strftime("%d %B",$action->action_start);
            $result = [$a,$b];
        }
        return $result;
    }
    
    function getSubs(){
        $result = [];
        $x = 0;
        foreach (wire('pages')->get(1080)->children() as $client) {
            foreach ($client->clientSubscriptions as $sub) {
                if( (int)$sub->number1 - (int) $sub->number2 <=5 ){
                     $result[$x]['fio'] = $client->title;
                     $result[$x]['left'] = round( (float)$sub->number1 - (float) $sub->number2 , 0, PHP_ROUND_HALF_DOWN);
                     $result[$x]['action'] = getNextAction($client->id) ?? false;
                    $x++;
                }
            }
        }
        return $result;
    }

     

  5. Can anyone tell me how to find pages in propper way))
    Now i solved taks like this
     

    //$place = 1036
    //$type = 1122
    //doctors_office = page field with multiselect by checkbox
    //direction_category  = page field with select field for one value can be choosen
    
     foreach ($pages->find("template=doctor") as $doc) {
    	 	foreach($doc->doctors_office as $item) {
    		  if($item->id == $place){
    		  	if($doc->direction_category->id == $type){
    		  		$list[] = $doc->title;
    		  	}
    		  }
    		}

     

  6. Could anyone tell my how to make thing like this:

    1) When subpage for page with special template is created in admin than no fields to enter "title" and "name" is displayed - page creates automatic skipping this step and it has "name" and "title" like so - "post_1122"

    2) And of course if this page is created from script - things go the same.

    I think hooks can help by i don't know how to use them in my case.

    Thanks a lot.

  7. On 28.02.2017 at 5:02 PM, BitPoet said:

    Never done that (I usually use responsive CSS frameworks like UIkit to allow smooth scaling with a single set of templates), but you might have a look at @justb3a's MobileDetect module. With it, you should be able to adapt the paths (with code in site/init.php, not config.php, since the module needs to be initialized first) like in this recipe.

    Thanks for recipe. It works well but i can't get values before selecting template (

    So if i put this code in init.php nothing works. I think it's because at this step there is no variable mobileDetect

    if($config->mobileDetect->deviceType!='desktop'){	
        $config->urls->templates = $config->urls->site . 'm_templates/';
        $config->paths->templates = $config->paths->site . 'm_templates/';
    }

     

  8. Hi all.
    I need to change $config->paths->data['templates'] value from "templates" to "m_templates" for example.

    I think this wil be more easy to use specific folder for mobile view.

    How to change depending on some actions? (detecting if site viewing on mobile browser)

    Thanks

  9. Hi all. Could anybody help with this:
    I have two domains: site1.domain.com and site2.domain.com
    They are hosted at one server and put in folders
    site1: /home/site1/public
    site2: /home/site2/public
    (for example)
    All processwire files are in site1 folder and this site goes well.
    I put file index.php in site2 folder with the same content as it is in site1 folder but only changed $rootPath to path for site1 folder
    But still i can use only api but site doesn't loads the same way as site1

    I need to you use one installation of prw to load site at two domains (copy)

    What i need to do to start it works!?

  10. 12 hours ago, Robin S said:

    You could group some config fields inside a fieldset and set it to collapsed.

    
    $fieldset = $this->modules->get("InputfieldFieldset");
    $fieldset->collapsed = Inputfield::collapsedYes;
    // add some fields to $fieldset

     

    And how to add them via api in module.config file?

×
×
  • Create New...