Jump to content

neosin

Members
  • Posts

    107
  • Joined

  • Last visited

Posts posted by neosin

  1. @fbg13 thank you, Sorry I don't quite grasp this explanation since the people page only uses "title". Are you saying I need yet another template and fields to merge the "people" and "roles" for each video? The people and roles are "predefined" and exist already

    Here is my current setup:

    Template name: videos
    field: title
    field: body
    field: people type: asmselect

    Template name: people
    field: title

    Template name: roles
    field: title

    ideally this is what an editor would see when editing a videos template record

    field "people":  [drop down list of names] [drop down list of roles] [button "ADD"]

    example usage for new video page record: 

    title: Example Video
    body: Video description
    people:
    [ "Bob Smith" ] [ "Producer" ]
    [ "John Doe" ] [ "Director" ]
    [ "Bob Smith" ] [ "Catering" ]
    [ "Bob Smith" ] [ "Sound Editor" ]

  2. I have a template that allows multiple "people" records to be attached (basically tags) however each of those "people" can also have multiple "role's" selected from a drop down.

    is it possible for tags to have tags and if so how can it be accomplished?

    For example a "video" data page where the content editor can add multiple people names (via select list) and the roles of each person (via select list)

    I am probably over complicating this in my head again regarding how to do it in PW, any help de-muddling this in my mind would be much appreciated

    I have the add multiple names working using asmselect but am not sure how to add the select role option dynamically to each name once added.

    I am thinking there should be a table with 2 columns where the first column is the user name and the second column is the role and when you insert new record it adds a new row allowing to select a single name and role for the new insert.

    The "people names" and the "roles" come from different templates since people can have different roles in different videos

    thank you

     

     

  3. 9 minutes ago, adrian said:

    I haven't used this module, but I have used @Macrura's Settings Factory which is awesome. Is there any reason to consider this module over Settings Factory? Genuine question because I don't know what the differences are :)

    @adrian  do you have a link for this module? I searched " Settings Factory " in the modules section and it returned zero results.

    I am curious to check it out

    thank you

  4. @SamC   Best practice is to sanitize everything a user sends to server, never trust users. It is easy to hack forms using just your browser "developer tools" it lets you change values of everything including all form values. Using your example colors values, the values could be changed to do multiple things from "using unsuported other values" to injecting SQL or PHP code for whatever nefarious purpose.

    The only time you can relax is if you have predefined values and match those values to what is sent to the server.

    For example in your case, on form submit you could compare the gridRadios array to a PHP array of values to see if there is any match, if so then data is valid and proceed otherwise reject submission as invalid.

    but 99.9% of the time it's best to just sanizite user input

     

    • Like 1
  5. I see this frequently when editing existing PageTable fields within a template (in modal) and also directly in setup>fields>pagefield_name

    Quote

    Warning: count(): Parameter must be an array or an object that implements Countable in F:\htdocs\pw3098\wire\modules\Fieldtype\FieldtypePageTable.module on line 278

    this function seems to be the culprit

    	/**
    	 * Get the Inputfield used for input by PageTable
    	 * 
    	 * @param Page $page
    	 * @param Field $field
    	 * @return Inputfield
    	 * 
    	 */
    	public function getInputfield(Page $page, Field $field) {
    		$inputfield = $this->modules->get('InputfieldPageTable');
    		$value = $page->getUnformatted($field->name); 
    		$inputfield->attr('value', $value);
    		$templateID = $field->template_id;
    		
    		if(!$field->parent_id && !empty($templateID) && $page->numChildren > count($value)) {
    			$orphans = $this->findOrphans($page, $field); 
    			if(count($orphans)) $inputfield->setOrphans($orphans); 
    		}
    		
    		return $inputfield; 
    	}

     

  6. @adrian tyvm

    if anyone needs example of insert custom field before other form fields:

    wire()->addHookAfter('ProcessPageEdit::buildForm', function($event) {
        $pp = wire('pages')->get(wire('input')->get->id);
        $form = $event->return;
        $field = wire('modules')->get("InputfieldMarkup");
        $field->label = 'TEST';
        $field->value = $pp;
        $field2 = $form->get('title'); // Field to find and insert new field "before" it
        $form->insertBefore($field,$field2);
    });

     

    • Like 3
    • Thanks 1
  7. @adrian thank you, I will use this runtime markup fieldtype

     

    On a side note, using hooks how would you put a non editable field at the top of a form?

    this is what I had come up with before seeing your reply above, the results are it gets added but under the save button.

    For learning purposes, how would I make it added at the top of the existing form fields (if it is even possible)?

    wire()->addHookAfter('ProcessPageEdit::buildForm', function($event) {
        $pp = wire('pages')->get(wire('input')->get->id);
        $form = $event->return;
        $field = wire('modules')->get("InputfieldMarkup");
        $field->label = 'TEST';
        $field->value = $pp;
        $form->append($field);
    });

     

     

     

  8. just wanted to mention that this works fantastically for multilingual sites, thanks @adrian

    yoursite.com/en/pageID

    yoursite.com/fr/pageID

    yoursite.com/de/pageID

    :)

     

    I also modified the module slightly so that the "shortlinks" only display for superuser

    in the module file

    	public function ready() {
    
    		// we're interested in page editor only
    		if(wire('page')->process != 'ProcessPageEdit') return;
    
    		// skip changing templates (only target the actual edit form)
    		$id = (int)$this->input->get->id;
    		if(!$id) return;
    
    		// wire('page') would be the page with ProcessPageEdit
    		// GET parameter id tells the page that's being edited
    		$this->editedPage = wire('pages')->get($id);
    
    		// don't even consider system templates
    		if($this->editedPage->template->flags & Template::flagSystem) return;
    		// Display only for superuser so get current user and check if user is superuser
    		$user = wire('users')->getCurrentUser();
            if($this->isAllowed($this->editedPage) && $this->editedPage->id != 1 && $user->isSuperuser()){
    			$this->addHookAfter('ProcessPageEdit::buildForm', $this, 'addShortURLLinks');
    		}
    	}

     

    • Like 1
  9. I have a template with a field using profields page table and when I add children they do not get added to the table list automatically.

    Instead, when I add a child it appears under the table and I must select new children and to add to the table and click save, then they display in the table. The message displayed is " Children were found that may be added to this table. Check the box next to any you would like to add. "

    Is there a way to have them added automatically to the table when they are created in the admin instead of having to add them afterwards?
     

×
×
  • Create New...