neosin Posted April 11, 2018 Share Posted April 11, 2018 I need to display the page id when view/edit a page in the admin, I am not sure how to do this. Basically it is a field that the user cannot edit, it will show a url to the page with the id in it, like this; www.site.com/en/pageID This is so CMS users can share the short url. I am using @adrian's redirect module to enable redirect using page IDs. Link to comment Share on other sites More sharing options...
neosin Posted April 11, 2018 Author Share Posted April 11, 2018 ok this can be deleted, looking at @adrian's redirect module, it seems I need to create a hook in admin.php and then add the field to the form. Sorry, still trying to muddle my way through PW lol Link to comment Share on other sites More sharing options...
adrian Posted April 11, 2018 Share Posted April 11, 2018 This will let you do what you want: http://modules.processwire.com/modules/fieldtype-runtime-markup/ 4 Link to comment Share on other sites More sharing options...
neosin Posted April 11, 2018 Author Share Posted April 11, 2018 @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); }); Link to comment Share on other sites More sharing options...
adrian Posted April 11, 2018 Share Posted April 11, 2018 insertBefore or prepend https://processwire.com/api/ref/wirearray/insert-before/ https://processwire.com/api/ref/wirearray/prepend/ 1 1 Link to comment Share on other sites More sharing options...
neosin Posted April 11, 2018 Author Share Posted April 11, 2018 @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); }); 3 1 Link to comment Share on other sites More sharing options...
Mackski Posted July 16, 2018 Share Posted July 16, 2018 On 4/12/2018 at 1:32 AM, neosin said: @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); }); If I'm adding a custom field I also take it that I'll need to create a schema etc to store the values? Is there a way to adding abitry fields to a page in admin similar to notes, description fields without defining a schema? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now