Jump to content

name field in Content instead in Settings tab


seddass
 Share

Recommended Posts

Hi, all. Sorry if this is already mentioned somewhere but i couldn't find it in the forum.

There was an issue when clients updates the "title" field but forgot to update the "name" field. I think I have saw a way to move the "name" field from Settings to Content tab with a checkbox somewhere in template settings. Now it is gone.

Is it still possible?

Thanks in advance.

P.S.

I agree that it is not goot to change the page urls.

Link to comment
Share on other sites

Edit your /site/config.php and locate the line that says $config->advanced = false; Change it to true. Now when editing our template, you'll see a "system" tab. Click on that tab and check the box that says to show the name field on the content tab. Save. Your name field should now show on the content tab for pages using that template.

You don't want to keep $config->advanced on as it's meant for PW core/system development rather than regular development, and it can get you in trouble (I always keep it off unless I need something in it temporarily). So go back immediately and edit your /site/config.php and set advanced back to false.

  • Like 1
Link to comment
Share on other sites

Btw is it planned to have access management per tab? I remember Ryan mentioned that per field access management is coming (it would allow great workflows etc) and I assume that this would allow us to have per tab management too? (at least for custom tabs, but how about settings tab?)

Link to comment
Share on other sites

I hadn't planned on per-tab access control, though I suppose it would make sense with field-level access control since tabs are defined as fields containing other fields. Items under children, settings and delete already have granular access control, so worry a little about confusion from bringing in tab access control. But will give this more thought and consideration as we get into development of field-level access control.

Link to comment
Share on other sites

  • 4 weeks later...

Edit your /site/config.php and locate the line that says $config->advanced = false; Change it to true. Now when editing our template, you'll see a "system" tab. Click on that tab and check the box that says to show the name field on the content tab. Save. Your name field should now show on the content tab for pages using that template.

How to do this from API? Need this in one module I am building.

Link to comment
Share on other sites

Ahh.. I actually totally misunderstood that quote from Ryan :)

What I need to do is to add new fields to settings tab. Is that currently possible?

EDIT: And thanks and [applaud] Soma! You are so helpful that I am beginning to think your help as granted...

Link to comment
Share on other sites

To add something to the settings tab, hook into ProcessPageEdit::buildFormSettings

It returns an InputfieldWrapper that you can append() or prepend() fields, or you can even do something like this:

<?php
$wrapper = $event->return; 
$templateField = $wrapper->get('template'); 
$myField = wire('modules')->get('InputfieldText');
$myField->attr('name', 'hello');
$myField->label = "Hello there";
$wrapper->insertAfter($myField, $templateField); 
$event->return = $wrapper; 

But I think it's better to just append or prepend to the the wrapper, because you don't really know for sure which fields will be active on the settings tab. Also note that on some pages, there is no settings tab.

Link to comment
Share on other sites

  • 2 years later...

Hi,

I am wondering if we can also we move the fields on the template (global field) to the settings tab. I am having a bit of issue understanding of what needs to be done.


	/**
	 * Initialize the module
	 *
	 * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called
	 * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. 
	 *
	 */
	public function init() {
		// add a 'hello' method to every page that returns "Hello World"
		$this->addHookAfter('ProcessPageEdit::buildFormSettings', $this, 'example');
	}

  public function example($event) {

    $page = $event->object->getPage();
    $form = $event->arguments("form");

    echo $page->template;
    print_r($form);
    $wrapper = $event->return;
    $templateField = $wrapper->get('template');

    $myField = wire('modules')->get('InputfieldText');
    $myField->attr('name', 'hello');
    $myField->label = "Hello there";
    //$wrapper->insertAfter($page->get('title'), $templateField);
    $event->return = $wrapper;
  }

Can this be done? I wonder :( Thanks

Link to comment
Share on other sites

You've to use a 'lower' hook:

$this->addHookAfter("ProcessPageEdit::buildForm", $this, "example"); // 

From there you can find all tabs

// settings tab
$settings = $form->find("id=ProcessPageEditSettings")->first();

// content tab
$content = $form->find("id=ProcessPageEditContent")->first();

// view tab
$view = $form->find("id=ProcessPageEditView")->first();

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Think I misunderstood something.

Enabled $config->advanced and thought I will see all fields and tabs (maybe as fieldgroups) within template field chooser/rearranger so I can manage them like any other field or fieldgroup.

Wanted to move the page status fieldgroup to the bottom of the content tab to make it a little clearer.

I know it would work with a hook, but thought if possible with congif->advanced why use a hook when I can have drag'n'drop fun :D

Link to comment
Share on other sites

  • 1 year later...

ok i wanted to make sure that i did not miss any settings only visible when doing additional things like "show also system fields" and so on...

i guess hooking into buildform and then something like that: https://processwire.com/talk/topic/5294-field-columnwidth-via-api/?p=50948 ?

will try that later

If you can't get that to work, you could try adding a dedicated field to the content tab and adding a save hook to take it's value, sanitize it as a page name and then use it to populate the page name.

I am also curious as to your reasoning for this - if it's to make it easier for editors to remember to update it, then maybe you should just install https://processwire.com/talk/topic/7724-page-rename-options/ - even if it's only installed during development of the site, and then uninstalled once live to protect URLs from changing automatically?

  • Like 1
Link to comment
Share on other sites

thank you adrian, that's a good idea and i would definitely be able to do that. i'll try the other way first to learn a different approach.

the reason is related to this post:

https://processwire.com/talk/topic/10804-module-runtimemarkup-fieldtype-inputfield/?p=114147

i have a button that does some additional logic on page copy (copy the event but remove all available bookings). after copy the new page has a path like "event-1". i don't think that my client will find his way into the settings tab so i put it in the content tab and it is the first thing he sees after the copy. but its only a workaround for the linked post...

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...