Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Zeka

  1. Hi @Mackski

    wire()->addHookAfter("ProcessField::buildEditForm", function(HookEvent $event) {
    	$form = $event->return;
    	$process = $event->object;
    	$f = $process->getField();
    
    	$t = $this->wire(new InputfieldWrapper());
    	$t->attr('title', $this->_x('HelpTipContent', 'tab'));
    	$t->attr('class', 'WireTab');
    	$t->attr('id', 'help_tip_tab');
    
    	$field = wire('modules')->get('InputfieldTextarea');
    	$field->attr('name', 'helpTipContent');
    	$field->attr('value', $f->helpTipContent);
    	$field->collapsed = $f->helpTipContent ? false : true;
    	$field->label = __('Help tip content');
    	$field->description = __('Enter the help tip content that will appear in the tool tip.');
    
    	$_form = $this->wire(new InputfieldWrapper());
    	$_form->attr('id', 'helptip_inputfield_wrapper');
    	$_form->append($field);
    
    	$template_delete_tab = $form->find('id=delete, class=WireTab')->first();
    
    	$t->add($_form);
    	$form->insertAfter($t, $template_delete_tab);
    	$event->return = $form;
    });
    
    wire()->addHookBefore('ProcessField::executeSave', function($event) {
    	$field = wire()->fields->get($this->input->post->id);
    	$field->set('helpTipContent', $this->input->post->helpTipContent);
    });
    
    // at render time
    wire()->addHookAfter("Inputfield::renderReadyHook", function($event) {
    	$inputfield = $event->object;
    	d($inputfield->get('hasField')->helpTipContent);
    });

    I have tested it with several types of inputfields and it works. But I'm not sure about this part 

    d($inputfield->get('hasField')->helpTipContent);

     

  2. Hi.

    I'm trying to save an xls file to temp folder

    ....
    $writer = IOFactory::createWriter($spreadsheet, 'Xls');
    $wireTempDir = wire('files')->tempDir('testname' . time());
    $writer->save($wireTempDir->get() . "featuredemo.xls");

    The issue is that $wireTempDir return the path to temp folder like 

    D:/laragon/www/p/app/site/assets/cache/WireTempDir/.testname1531040249/0/

    But it creates only .testname1531040249 folder without subfolder '0'.

    Am I missing something?  

  3. $allbooks = $pages->find("template=book, sort=$sort, $q, $tagged, $select_studio, limit=10");
    
    if ($input->get()->count() && !$allbooks->count() && $input->pageNum > 0) {
    	$url = $page->url([
    	      'http' => true,
    	      'pageNum' => 0,
    	      'data' => $input->get()->getArray()
    	    ]);
    
    			$session->redirect($url);
    }

    Not tested and may result in redirection loop, but just an idea. 

    Tested, it works. 

    • Like 1
  4. Hi.

    I want to show emojis in page's title and description. But while saving a page text that goes after an emoji gets stripped. 

    I'm using utf8_general_ci as charset, but for title and descriptions tables I've changed it to utf8mb4_general_ci. Even after that 4-byte emojis saves as ???? in DB. 

    Is there something that I missed? 

    Thanks. 

  5. I think you have to unzip it firstly and then add images to your images field

    $zip = $config->paths->cache . "archive.zip";
    $dst = $config->paths->cache . "temp-zip/";
    $items = $files->unzip($zip, $dst);
    $page->of(false);
    if(count($items)) {
    	foreach($items as $item) {
    		$page->images->add($item);
    	}
    }
    $page->save();

     

    • Like 1
×
×
  • Create New...