Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Custom Fields

edited June 2012 in Future

It would have been a nice feature if we'd have the possibility to use custom fields when you add a new blog post.

Comments

  • Custom fields such as what?

  • I definitely plan on adding custom fields at some point, which is why the blog\Post class extends ExtendedModel already. Still figuring out the best way to configure the custom field list though (will need to be the same solution for adding custom fields to users too).

    One possibility is adding them to the form validation files (apps/blog/forms/add.php and apps/blog/forms/edit.php) like this:

    [custom:location]
    
    label = Location
    field_type = select
    ; etc.
    
    [custom:more_info]
    
    label = More info link
    field_type = text
    ; etc.
    

    That would be easy enough to add, but means you'll have to edit those files to add them. So that may be the resulting storage format for the custom field settings, but I'd like to make that easier for end users too :)

  • edited June 2012

    yes this would work out too but as you mentioned you have to edit those files to achieve that. I was thinking more like the way wordpress custom fields are working. Example: If i want to add a h3 subtitle to the post or a div with a special css rules or maybe a link to an external image, because most of the time when you have to deal with loads of content its much easier to just paste the link to the image that has been already uploaded in a server.

  • Definitely something closer to Wordpress from a UI standpoint for sure, regardless of how it's handled behind the scenes. Maybe something like this:

    1) Adding a "Manage custom fields" link on the "New Post | Import Posts" line that goes to a screen where you can define the custom fields, their labels, types, etc.

    2) In the add/edit views, call an embed in the form, e.g., {! admin/util/extended?extends=blog\Post !}

    3) The admin/util/extended handler would generate a "Custom Fields" section to the form, similar to how "Extra Options" works, that reads the extended fields defined in step 1.

    4) Add a method to ExtendedModel so that in the form handling you can just say $post->update_extended ($_POST);

    This could then work across types. For custom CRUD applications, they could add a link that ties into the custom fields screen in step 1, then add the extra lines of code from steps 2 and 4, and it should be able to link up with any ExtendedModel-based class.

    I'm going to file an issue on Github to keep track of this, I think this could be a good solution, and would be seamless to the user from a UI perspective.

  • Yes this solution would be perfect :) From a Front End perspective this option gives unlimited design possibilites

  • Would this be the way to include custom fields in user signup/update forms? I think something like {! admin/util/extended?extends=user\User !} would require an admin user, but what if the users are members, not admins?

  • I recently added a bunch of (optional) new fields to the user table, so that may help a bit here.

    To create custom user signup and update forms, you would override them with your own handler in the [Custom Handlers] section of conf/app.user.config.php (which is created the first time you edit the settings under Tools > Members > Settings). From there you can add any of the new fields as well as any extended fields you define through Tools > Members > Custom Fields in your custom PHP code.

    If you need to allow users to create their own custom fields, that can also be done with custom signup/update forms and setting them via the ExtendedModel features, since technically the extended field can store any properties you want, not just ones defined via the GUI.

    Let me know if that answers your question.

Sign In or Register to comment.