Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Zeka

  1. As @Macrura said in most cases ProCache and WireCache is the way to go for me. Also what I have found super useful is namespaces for WireCache, as for the example you can load all cache for a page with namespaced cache and preloadFor method just with one query. 

    7 hours ago, Macrura said:

    Another thing that is interesting to do is $cache within $cache, ... had to do it in a few places, it was tricky, but it really made a difference in speed..

    There is CacheNesting module, I haven't used it but it should help to handle such scenarios

    https://modules.processwire.com/modules/cache-nesting/

    • Like 4
  2. Hi. 

    I have CKEditor field with the name 'wysiwyg'

    In config.js and config-wysiwyg.js I have such code

    CKEDITOR.editorConfig = function( config ) {
    	// Define changes to default configuration here. For example:
    	config.language = 'ru';
    	// config.uiColor = '#AADC6E';
    };

    File config-wysiwyg.js get loaded on the page edit screen, but the language is not changed. But if I put 'language:ru' to 'Custom Config Options' on the field edit page everything works as expected. What is strange, that is if I try to change UI color via config-wysiwyg.js - color get changed.

    CKEDITOR.editorConfig = function( config ) {
    	// Define changes to default configuration here. For example:
    	config.language = 'ru';
    	config.uiColor = '#AADC6E';
    };

    So it looks live there is some special case with language property. 

    Did somebody have such behavior? I want to have all field-relative settings in the one file to not get a mess.

  3. Just a note about fonts. Maybe we should consider fonts with the Cyrillic glyphs support? In the longer term, there probably maybe some messages on the forum or even parts of documentation translation in Ukrainian or Russian languages. Without Cyrillic glyphs, this parts will fallback to another font and it will look not consistent with other parts. 

    • Like 4
  4.  

    $this->addHookAfter('ProcessTemplate::buildEditForm', function ($event)
    {
    	$form = $event->return;
    	$template = $event->arguments[0];
    	$icon_field = $form->find('name=pageLabelIcon')->first();
    	$icon_field->collapsed = Inputfield::collapsedHidden;
    
    	$field = $this->modules->get('InputfieldText');
    	$field->attr('id+name', 'template_emoji');
    	$field->icon = 'list-ol';
    	$field->attr('value', $template->template_emoji);
    	$field->columnWidth = 100;
    
    	$form->insertAfter($field, $icon_field);
    	$event->return = $form;
    });
    
    
    $this->addHookBefore('ProcessTemplate::executeSave', function ($event)
    {
    	$template = $this->templates->get($this->input->post->id);
    	$template->set('template_emoji', $this->input->post->template_emoji);
    });
    
    $this->addHookAfter('ProcessPageListRender::getPageLabel', function ($event) {
    	$page = $event->arguments('page');
    	$template =  $page->template;
    
    	if($template->template_emoji) {
    		$event->return = $template->template_emoji . ' ' . $event->return;
    	}
    });

    420464969_2019-01-0722_12.03djytg.png.8f0af41037954d5206ceb7bbca4c6684.png

    • Like 6
    • Thanks 1
  5. @BFD Calendar You got 

    Fatal error: Uncaught Error: Call to a member function each() on null in 

    So you have to make sure that the is workshops_list is populated and contains an iterable object that extended from WireArray, so you can use each method on it.

    if(count($item->workshops_list)) {
    	$out .= $item->workshops_list->each(
    		"<font color='green'>| {title}</font>"
    		);
    }
    

     

    • Like 2
  6. Hi.

    Is it possile to use Inputimagefield on a process module page? 

    $f = $this->wire('modules')->get('InputfieldImage');
    $f->setAttribute('name', 'image');
    $f->label = $this->_('Image');
    $f->columnWidth = 75;
    $markup->add($f);

    This code renders field but it obviously doesn't work) I have read somewhere on the forum that this input type intended to work in the context of page edit, so it's not possible to use it on a module config page, but process page is actually a page, so I thought there is might be the way how to get it working.

    Thanks, Eugene.

     

  7. 42 minutes ago, felixthecat said:

    Thank you... that is working ?
    But what is the relation between pagimages and the field?

    Here is the description of Pageimages class

    ProcessWire Pageimages
    
    Pageimages are a collection of Pageimage objects.
    
    Typically a Pageimages object will be associated with a specific field attached to a Page. 
    There may be multiple instances of Pageimages attached to a given Page (depending on what fields are in it's fieldgroup).

    https://processwire.com/apigen/class-Pageimages.html

    • Like 2
  8. 11 minutes ago, kongondo said:

    I've only had a quick look at your post. It could be 'default' is a reserved word/keyword?

    No, it behaves in that way when different 'keys' have the same values. One more example

    $array = WireArray([
        'test' => 'test1',
        'test1' => 'test1',
        'test2' => 'test2'
    ]);
    
    d($array);
    
    
    count => 2
    items => array (2)
      - test => "test1" (5)
      - test2 => "test2" (5)

    Actually, I think that it's a bug in WireArray() function as if use new WireArray() it works as expected

    $test = [
        'test' => 'test1',
        'test1' => 'test1',
        'test2' => 'test2'
    ];
    
    $array = new WireArray();
    $array->setArray($test);
    
    d($array);
    
    count => 3
    items => array (3)
     - test => "test1" (5)
     - test1 => "test1" (5)
     - test2 => "test2" (5)

    Here is code for WireArray();

    public static function newInstance($items = null, $class = '') {
    		if(empty($class)) $class = get_called_class();
    		/** @var WireArray $a */
    		$a = new $class();
    		if($items instanceof WireArray) {
    			$items->wire($a);
    			$a->import($items);
    		} else if(is_array($items)) {
    			$a->import($items);
    		} else if($items !== null) {
    			$a->add($items);
    		}
    		return $a;
    	}

    So the issue is in the usage of import method as it skips any items already present in WireArray.  

    • Like 2
×
×
  • Create New...