Jump to content
blackeye1987

Custom Field in Page SettingsTab

Recommended Posts

Hi Everyone,

i couldn't find a way to put a custom field into the settings tab

i'd need that field only as a superuser, to hide pages from my own search engine.
best would be a custom status, but a checkbox in the settingstab would be the smoothest solution

i wasn't able to find anything like that in the forum so far.


feel free to move the thread, if i am in the wrong subforum
 

Share this post


Link to post
Share on other sites

Here's a short snippet for site/ready.php that hooks after ProcessPageEdit::buildForm and moves a regular field (named "testfield here") from the Content tab to Settings. The methods used are from the InputfieldWrapper class.

<?php

wire()->addHookAfter("ProcessPageEdit::buildForm", null, "moveFieldToSettings");

function moveFieldToSettings(HookEvent $event) {
	$form = $event->return;
	
	$field = $form->find("name=testfield")->first();
	
	if($field) {
		$settings = $form->find("id=ProcessPageEditSettings")->first();
		// Alternatively, find a specific field to insert before/after:
		// $settings = $form->find("name=template")->first();
		
		if($settings) {
			$form->remove($field);
			$settings->append($field);
			// In the alternative, insert before or after the found field:
			// $form->insertBefore($field, $settings);
		}
	}	
}

 

  • Like 10

Share this post


Link to post
Share on other sites

You could also just use the field access settings to not show the field to anyone besides superusers.

  • Like 5

Share this post


Link to post
Share on other sites

@LostKobrakai - this would miss the feel of having it in the settings tab, besides yes i could make a custom settingsTab, but this would also miss my approach.

i am not looking for a quick solution more for a clean or even expandable solution.

using @BitPoet's approach , i am more flexible and able to communicate with my team and the customer.

having hidden fields through content tabs might give an irritational feel when working with customers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By alanxptm
      Hi, first time here.
      I've been working on my first site with PW and it has been a pleasure, I'm around 75% of structure and logic completion I think, and polishing some things now.
      My question is: I have a parent 'category' page that musn't be editable by the author role, but they must be able to add children 'post page' to the 'category'.
      I've been playing with the settings and can just let the author create childs if is able too to edit the parent category, so.. How can I do it?
       
       
    • By MateThemes
      Hello everyone!
      I have searched the forum for quite a long time and I tried some solutions for my topic but nothing seems to work.
      I need to create a Settings Page and for a native feeling I want to create it under the main navigation on top. The settings page should hold the Main Logo, some styling and other settings. As I said nothing seems to work for me. I tried to create a Page under Admin with Admin Template and ProcessPageEdit but then I can't assign an image field. 
      I don't want to write a module because it is to much work for only 3 settings.
      I hope someone of the forum could help me out!
      Have a nice day!
    • By benbyf
      HELLO! I always struggle adding additional functionality, buttons and other settings to the CKeditor and I guess other people might have the same issue at times.
      For those who are CKeditor aces would you share your settings in this post to help others with what I guess should be a simple task to extend the default settings.
       

      Extra color select and text formating
      toolbar
      Format, Styles Bold, Italic, Underline, -, RemoveFormat TextColor, BGColor JustifyLeft , JustifyCenter, JustifyRight, JustifyBlock NumberedList, BulletedList, -, Blockquote PWLink, Unlink, Anchor PWImage, Table, HorizontalRule, SpecialChar PasteText, PasteFromWord Scayt, -, Sourcedialog extra allowed content
      small[*] section font[style] span[style]{!color} code[*] custom config options
      colorButton_colors: ec4626,ffde43,00aaeb,004a87,7b9320,ffffff extra plugins
      colorButton  
    • By EyeDentify
      Hello There fellow PW gurus.

      I am trying to make a field show as open only if the field is filled out with at string.
      for example: "my_styles.css" and stay hidden if the field is empty.

      The field in question is of type "text" if that helps.

      And i put in the "show this field only if"
      css_filename!=''

      because the field name is "css_filename"

      But no mather what the field is closed because i have choosen it as "closed" as default.

      What am i doing wrong?

      i am running PW 3.0.83 Dev.
       


    • By Macrura
      This is the new topic for the Settings Factory module (formerly known as Settings Train).
      Repo:
      https://github.com/outflux3/SettingsFactory
      I'm not sure what versions this is compatible with, it has only been tested on 3.x branch;
      it is not namespaced, and i'm not sure if namespacing is necessary or a benefit for this module; if any namespace or module gurus can weigh in on this, let me know. I'm also not sure if there needs to be a minimum php version;
      I have one live site using this now and it's working great; But before submitting to mods directory, would be better if there was some additional testing by other users.
×
×
  • Create New...