Jump to content

Issue renaming the Title field within a context


lenoir
 Share

Recommended Posts

Hi,

I've got the following issue: I'm renaming the title field on the team pages of a website. Basically, it's confusing to enter the name of a member of the team in the title field… (specially when there's another field right underneath it called 'name').

So I've used the "context" function to change the field name, which works fine as soon as you've saved the new page. Before that, the field is still called 'title'. (see screenshots)

Any ways around this? Suggestions?

Also, is it possible to rename the 'name' field? I'd rather call it something like "URL Name", or something similar, to avoid confusion from the client.

Thanks!
David

post-588-0-69900000-1364290729_thumb.png

post-588-0-60256700-1364290730_thumb.png

Link to comment
Share on other sites

Hi lenoir, I've not used the Context facility before, thanks for drawing it to my attention; but I see your problem (that until the context is set your alternate name is not shown).

Others in the forum will likely come up with more complete solutions to suggest but one simple thing I do quite a lot is to use the Description for a field to inform the user; carefully worded copy there with for example emphasis provided by judicious use of uppercase can go a long way to providing a self explanatory experience for almost all levels of users.

Link to comment
Share on other sites

If you create a new child page, which can have multiple templates, the creating page process can't know which template you gonna choose. So it doesn't work the way you doing. Also in this case it wouldn't make sense as you don't know which template context should be displayed.

BUT if you have a setup where the parent page template only allows for 1 particular child template (under Family settings of parent template) it does take that template for the page creation step and you'll see the title in context.

The "name" field is built-in and a special field you can't change within fields setup.

But you can have a simple autoload module that renames the label to what you like. Although I think it's not an issue to have it "name", I understand people want to name it different.

A module like the HelloWorld.module, can be used as a starting point, with as hook and a function

// in init() method add a hook
$this->addHookAfter("InputfieldPageName::render", $this, "hookPageName");

and add a function below with this:

public function hookPageName(HookEvent $event){
    $field = $event->object;
    $field->label = "URL segment";
}
  • Like 3
Link to comment
Share on other sites

Wanted to add: Maybe the best way is to install Language Support (not installed by default) and use translation feature of PW to change the label of the name field.

Even if you don't need language support it would allow you to do it with few clicks and have it localized even.

If you only need one language you could use the default language and create a new translation. Enter the file name you want to translate/modify

The file that makes the page name field is /wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module

Once created you can see some fields to enter, look for "name", enter your text and save. Done.

  • Like 2
Link to comment
Share on other sites

Thanks to you both! 

@alanfluff: I use the description fields quite often as well and find it very handy. But I've noticed over the years that a CMS can't be too straightforward: some of our clients don't have much computer skills and they end up doing pretty creative stuff with their content if it's not 100% clear ;-)

@soma: Thanks for your suggestions. I guess the latter is more up to my coding skills, but i do like the simplicity of the module solution. However, I changed the famliy settings of the parent template as suggested and that solved my problem.

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.

  • Similar Content

    • By donatas
      Hi,
      Could someone please direct me to how should I go about using `addFlag` on a field in a fieldgroup context?
      Setting contexts through API is pretty new to me, however I managed to set all other necessary settings through `setFieldContextArray()` function. But the access flags are only applied through `$field->addFlag(128)` (when not inside fieldgroup context) - https://processwire.com/api/ref/field/add-flag/
      I have tried (in a module install function):
      // Create a new fieldgroup $fieldGroup = new Fieldgroup(); $fieldGroup->name = static::NAME; $fieldGroup->add('title'); // trying to set flag to this 'title' // ...Adding other few fresh fields to fieldgroup $fieldGroup->save(); // Works fine. $field_title = wire('fields')->get('title'); $fieldGroup->setFieldContextArray( $field_title->id, array( 'columnWidth' => 50, 'useRoles' => true, 'accessFlags' => [64,128], // Doesn't work. 'addFlag' => 128, // Doesn't work. )); //$fieldGroup->getField('title',true)->addFlag(128)->save(); // Doesn't work with field->save() nor without. $fieldGroup->saveContext(); // Works fine with above setFieldContextArray() settings. // Adding it to a new template and saving. Works fine. $template = new Template(); $template->name = static::NAME; $template->fieldgroups_id = $fieldGroup->get('id'); $template->save(); The API docs seem a bit lacking in this department, very hard to figure out the whole flow 🙂
      Any ideas? Thanks in advance!
    • By louisstephens
      So I ran into a strange error this morning when trying to publish a page. I went to publish a new page under "clients", but I get an error that says "Cannot be published until errors are corrected". I thought perhaps I had missed a required field so I checked, but none of the fields are marked as required. I then checked to see if I could just add a basic page (default basic-page.php template) under the homepage, but I get the exact same error when trying to publish. When looking at the template, I don't see any error messages being displayed above any fields.
      The odd thing I found though was if I got to "settings"  and uncheck "unpublished", I can then publish the page without errors. I did upgrade earlier today to the newest version to hopefully fix an issue I had yesterday (which it did). Has anyone run into this error before? 
      **EDIT**
      Well, after a lot of staring and pulling my hair out, I found the issues. I had installed multi-language support sometime ago (and due to the project changing, had to remove it). Apparently in my haste, I did not remove all the dependencies so it was still trying to check for the multi-language title (I am guessing) even though it actually wasnt on the page. I went through the database and removed it and can now save/publish pages without issues. 
    • By NehaPillai
      Hello Everyone, I was trying to update SEO meta title, description and meta keywords for my website in Process Wire CMS but it saving in the backend but it is not reflecting on my website, Please help me regarding this error. Please find below attached screen shot for your ref. TIA.


    • By AndZyk
      Hello,
      when you add a page you can see the page name of the page under the page title field. But when you change the page title afterwards, you have to go to the settings tab to also change the page name.
      We have many clients that change the page title afterwards but forget to change the page name, because they don't look in the settings tab or forget it.
      Is it possible to show the page name on the content tab under the page title?
      I hate to say this, but I like how WordPress handles this better:

      Or should I open an GitHub request?
      Regards, Andreas
    • By j00st
      Hi all! 
      I've been searching/browsing a bit, but can't find what I'm looking for just yet...
      Perhaps I'm searching in the wrong places, but I thought posting it here might work better/more efficient.
      I need to do the following;
      1. I have the TITLE field (the one set by ProcessWire as default).
      2. There's already a whole lot of pages of the template 'project' set up.
      3. Now I actually want to be able to add <i> and <br> tags to this title...which is possible if I turn off the specialchar encoder...
      ...but it also presents the opportunity for people to start typing, and generate the following kind of URLs:

      TITLE: This is a really long title <br> which <i>needs</i> to be split in two
      URL generated: this-is-a-really-long-title-br-which-i-needs-i-to-be-split-in-tow
      Don't want that happening. So, I thought it might be wiser to do the following.
      Next to the 'title' field, also set a 'display-title' field.
      But, preferably I'd want to generate this for all the projects already in existance...including copying their content to this new display-title field.
      Just adding the field means all the titles will need to be copied...not something I look forward to telling the editors of the site 🙂
      I saw the Hook for on-save, but that's only for the single page...and I'm not an experienced MySQL-coder/user, otherwise I guess that would've been the way to go.
      So I'm really curious to hear if you guys think there are other/better options (and what they are)
      Thanks!
×
×
  • Create New...