Jump to content

diegonella

Members
  • Posts

    42
  • Joined

  • Last visited

Posts posted by diegonella

  1. Hi @wanze,

    Slow in the admin to add a new field to a template, to move from one sector to anotherbetween templates, fields and other internal sections because I'm still in development and creating fields, assigning them to the templates.
     
    I am on a local development server, with processwire 2.6.1
     
    So I ask if any special configuration recommended for php, mysql or apache.
     
    Thanks
  2. I am developing a site of some 200 pages and I notice very slow, I wonder if there are any recommended especially for mysql configuration, guess who comes out there, because they are pages that have many fields.

    The server is Intel Core Duo, 2GHz, 4GB RAM, and I've tested both on Windows and Linux, since it has dualboot.

    Any recommendation?

    Thanks

  3. I am using the following code:



    $new_pt = new Page();
    $new_pt->parent = "/opt/";
    $new_pt->template = "pt_template";
    $new_pt->name = uniqid('pt-', true);
    $new_pt->title = "Title ".time();

    if ( $new_pt->save()) {
    $page->of(false);
    $page->pt_field->add($new_pt);
    $page->save();
    }


    and it turns out I inserted 2 pages, and I can not know where the problem.

    I'm using 2.6.1 PW

    Could give me a help, where my error.

    thanks

  4. Hello,
    I am wanting to hide the tree admin certain pages with a specific template, I tried to make a module, but I do not quite understand how to apply the hook
     
    This is my code
    public function init() {
    		$this->addHookAfter("ProcessPageListRender::getPageActions", $this, 'hookPageList1');
    		$this->addHookAfter("ProcessPageListRender::Execute", $this, 'hookPageList2');
    	}
    
    	public function hookPageList1(HookEvent $event) {
    		$page = $event->arguments[0];
    
    		if ( $page->template == "familiares" ) {
    			$actions = null;
    			$event->return = $actions;
    		}
    	}
    
    	public function hookPageList2(HookEvent $event) {
    		$page = $event->arguments[0];
    
    		if ( $page->template == "familiares" ) {
    			$event->return = false;
    		}
    	}
    

    As I apply the hook?

  5. Hi all, 

    I am listing a gallery of products and each product, there is the possibility of seeing a rapid or enter the product and see it in detail view. 

    I have the following structure 

    /products/product-a 

    and would like to pass on to the product in a segment to display quick view 

    /products/product-a/quick-view 

    There any way to use another template in runtime?

    Thanks

  6. @Pete,

    Diego wants to match two conditions - where the field is empty or where the same field has the id=123. I've tried with leaving it empty as you suggest (i..e, nothing after =) + specifying an ID but it doesn't work :). Diego used "standard" before, trying to match the name of the page referenced in the Page Field but we know PW does not store the name/title but the ID...Anyway, one gets the following error

    Fatal error: Exception: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias

    if you try  the selector (page_field=1234|) or other variants as I show in my examples above

    Yes, I'm using 2.3 PW

  7. Hello everyone
    I want to filter all children adicional_hab field (product type) is NULL or empty or has X page
     
    What I want is to filter all the pages that adicional_hab field is empty or has selected a value.
     
    To translate it into SQL
    SELECT * FROM adicional WHERE adicional_hab IS NULL OR adicional_hab = 'standard'
     
     
    I tried
    $adiconal->children("adicional_hab=standard|''");
     

    On the other hand there ay any way to make a print and view the sql query that is running with filters that these apply?

    Thank you very much, best regards

    Diego

     
     
  8. Hi,
    I have a number of pages with a template that has a repeater field (salida_fecha_repeater) which has 2 fields salida_fecha (type date) and salida_fecha_markup (float), when I show the pages, I have show the first available date, so I would not show dates before today.
     
    $salidas = $pages->get("/salida/")->children("limit=5,salida_fecha_repeater.salida_fecha>=".date("Y-m-d"));
    foreach($salidas AS $salida ) {
            $markup = $salida->salida_fecha_repeater->find("salida_fecha>=".date("Y-m-d"))->first(); # Test 1
    	#$markup = $salida->salida_fecha_repeater->first(); # Test 2
    	echo $salida->title." [".$salida->id."]"." | ".$markup->salida_fecha_markup."<br>";
    }
    
    With # Test 1 returns nothing
    With # Test 2 returns the first record in the repeater does not always correspond.
     
    Thanks in advance
    Diego
  9. Thank you very much Nik
    Yes, at the end I did with a hook
     
     
    public function init() {
    	$this->pages->addHookBefore('save', $this, 'hookSave');
    }
    
    public function hookSave($event) {
    	$page = $event->arguments[0];
    
    	# Guardar la ciudad de salida y arribo
    	if( $page->template == 'salida_child' && $page->isChanged('itinerario_destino_repeater') ) {
    		if ( count($page->itinerario_destino_repeater) ){
    			$salida_origen = $salida_destino = "";
    			foreach ($page->itinerario_destino_repeater AS $itinerario ) {
    				if ( $itinerario->itinerario_ciudad->id ) {
    					if ( $salida_origen == "" ) { $salida_origen = $itinerario->itinerario_ciudad; }
    					$salida_destino = $itinerario->itinerario_ciudad;
    				}
    			}
    			$this->message("Itinerario desde <b>".$salida_origen->title."</b> hasta <b>".$salida_destino->title."</b>");
    			$page->salida_origen = $salida_origen;
    			$page->salida_destino = $salida_destino;
    		}
    	}
    }
    
  10. I'm making a site for a travel agency, excursions in the section, which has a repeater field cities in which loaded the itinerary.
     
    Then in the search frontend need search all trips leaving from "berlin"
     
    Trips
       Trip 1
          Cities (repeater)
             Berlin
             Rome
             Paris
     
       Trip 2
          Cities (repeater)
             Paris
             Rome
     
     
    I need to find all the children in the repeater field equals berlin cities, but only the first record
    How do the selector?
     
    $p = $pages->get("/trips/")->children("cities_repeater.0.city=berlin");
    

    ??

  11. This is my code

    <form method="post" action="<?php echo $page->url;?>">
    <?php
    	$idiomas = $pages->get('/tabla/idioma/')->children();
    	foreach($idiomas AS $idioma) {
    ?>
    	<input type="checkbox" name="idiomas[]" id="idioma_<?php echo $idioma->id; ?>" value="<?php echo $idioma->id; ?>" <?php if ($page->htl_idiomas->has($idioma)) { echo "checked"; } ?>> <label for="idioma_<?php echo $idioma->id; ?>" class="label"><?php echo $idioma->title; ?></label>
    <?php } ?>
    <input type="submit" value="submit" />
    </form>
    

    What I could not do it when I get the POST, save the selected values

    if($input->post->btn_submit) {
    	$page->setOutputFormatting(false);
    	foreach($input->post->htl_idiomas- AS $idioma_id ){
    		$page->htl_idiomas = $pages->get((int)$idioma_id);
    	}
    	$page->save();
    }
    

    Can you give me a hand?

    Thanks

×
×
  • Create New...