Hi,
Is there a way to add another field than Title, URI and Template when creating a new page?
My point is to allow to have an Author field and be able to fill Title or Author (but not always both). The URI would be the combination of the two fields or only the filled one.
Thanks for your reply.
I tried to instal the plugin in a ‘talks’ folder and create a parent page called ‘talks’ but nothing append when I create sub pages. Did I miss something?
The plugin is just an example of hijacking the route, it uses the same form fields as the default modal. You would have to add the form fields you want in the form.php file and add the data to the page creation code in talks.php.
Sorry I was expecting the plugin to show something différent. It’s working perfectly!
So I added a new field. Any idea of how to create the UID from the combination of Title and the new field?
Another way would be to update the uid with JavaScript. I used this in a form for team members. There are additional fields called name and surename in the add form.
The form view (template.php) looks like this:
<div class="modal-content modal-content-medium" data-slug-table="">
<?php echo $form ?>
</div>
<script>
(function() {
$.slug.table = <?php echo slugTable() ?>;
var modal = $('.modal-content');
var title = modal.find('[name=title]');
var uid = modal.find('[name=uid]');
var surename = modal.find('[name=surename]');
var name = modal.find('[name=name]');
surename.add(name).on('keyup', function() {
var value = surename.val() + ' ' + name.val();
uid.val($.slug(value));
title.val(value);
});
uid.on('blur', function() {
uid.val($.slug(uid.val()));
});
})();
</script>