Moodle custom fields API for course page - php

Unfortunately I can't quite follow how the custom field API works. What I actually want are additional fields for the custom course format such as address, directions and other (hybrid courses). And no, I don't want to use the web interface for this.
As I understand it, two files are needed, myFormatPlugin/classes/customfields/course_handler.php
and
myFormatPlugin/customfield.php
Do I need to register the customfield.php file somewhere or does it work via autoload?
Do I need to create a separate database table for this?
What am I missing?
Could someone make an example for just one field? I don't find the github links in the documentation helpful either.

Hope you want to add some custom fields for your custom course format. To add custom fields for the format plugin you don't want to use the custom field API.
The course format plugin contains options to add your custom fields using the function course_format_options in your course/format/PLUGINNAME/lib.php.
Moodle will automatically store these custom course format options in the database table course_format_options.
Please have look at the designer course format plugin.
https://github.com/bdecentgmbh/moodle-format_designer/blob/master/lib.php#L241

Related

Kanboard Custom Fields

Customization work regarding Kanboard
I need to add custom fields to the create new task form. Can this be achieved using Metadata Manager plugin?
Will I need to hire a developer to get this done?
Currently there's only Title, Description & Tags available. I Just need to add three more fields to show in the task box in Kanban view.
Thanks!
No, the Metadata plugin will not achieve that. There is a plugin that will allow you to create custom fields that will be included on the create task form, but since you didn't ask, I cannot tell you which plugin (I tried already, and it was downvoted and deleted because it didn't answer your question apparently)
No, you will not need to hire a developer to get this done, assuming you can find the plugin I am referring to.
With said plugin, you will be able to add as many custom fields as you wish, as well as, including them in task exports, filtering, change their type, etc...
Good luck in your search!

Use custom post type or custom group within another one

I am working on a wordpress website and I am using Advanced Custom Fields and Custom post type UI plugins. What I want to do is that:
The website I am working on was in native php and I want to migrate from native to wordpress but I face this problem, I can't achieve the relations that I had in mysql, in the form of post type and custom field groups in wordpress and ACF.
SO any have an Idea how to do this.
I also checked reusable fields but It actually won't help
https://github.com/tybruffy/ACF-Reusable-Field-Group
You didn't post your Data Model so it's hard to tell what the issues are or to give you an example based on it.
However, regarding the way Wordpress handles custom post type and meta value, I suggest that you consider post types as entities while meta values (custom fields here as you used ACF) usually their properties.
Usually, modelling 1-M or M-M relationships can be done in Wordpress by introducing custom taxonomies normally solve the problem, since it works as a mechanism to classify, to categorize and to group your entities. An example of this is the way Woocommerce give options to treat their product attributes as custom taxonomies. You can view the code from the link below.
https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1398-1417

Moodle - Plugin to create forms

I'm new to Moodle and there is a new project in my office that I want to do.
What I want to do is to create a plugin that helps you create forms. For example, if I want to create a simple register form within Moodle or a simple questions form, the plugin must be able to manage the different type of labels (mail, text, drop-down, select, check, etc.), store the form in a database (form1, form2) and create the table for the respective form.
How should I approach this? Is this possible in Moodle? Or do I just code it in another language and make a generator? Maybe a local plugin?
Thanks in advance.
There is something similar in Moosh although I haven't tried it myself.
http://moosh-online.com/commands/
moosh generate-form form_name
It is possible. There is at least one existing form builder plugin for Moodle that could serve you as a good inspiration source:
repo: https://github.com/WisdmLabs/moodle-local_edwiserform
docs: https://edwiser.org/forms/edwiser-forms-documentation

Modify how Drupal builds fields on a per form basis

I want to change the way Drupal builds specific fields on a specific node edit/add form on my site. For example, when I use print drupal_render($form['textarea']); in my node--CONTENTTYPE--form.tpl.php file, I get the default Drupal render of the field widget. I want to modify the HTML markup of the field widget.
There are three ways I can think of that might solve this problem:
Using a forms equivalent of the theme_field() hook. This seems ideal, but after searching for the last few hours, I haven't found anything on this.
Building custom field widgets for every field type I'm using on that node. This is definitely not ideal and I have to believe there's an easy way to do this in Drupal from a theme point of view.
Manually build the HTML markup for the form and field in node--CONTENTTYPE--form.tpl.php with print $form['textarea']['und'][0]['title']; and the like.
Is there a hook in Drupal to do this, or must the code for every field I want to modify be manually generated?
I think the hooks you are looking for are hook_form_alter and hook_form_BASE_FORM_ID_alter. Refer to the Form API to know what you can set on the render array.

Creating WP custom post types with custom fields from database

I'm working on a Wordpress website that uses an external system to sell tickets. This ticket system provides a WordPress plugin that automatically creates and updates two new WordPress database tables: events and shows. That's great, but that's all this plugin does.
I have used the Database Browser plugin to test if the database tables created by the ticket system plugin were there and that was the case. I can see all the data there too. So far so good.
I now need to create custom post types (events and shows) with custom fields using the data from these database tables. I've searched, but I can't seem to find out how to create custom post types that pull their data from existing database tables.
Maybe I'm looking at this all wrong. Any help to point me in the right direction?
To create custom post refer this http://codex.wordpress.org/Post_Types#Custom_Post_Types
And use this plugin to create custom field http://wordpress.org/plugins/advanced-custom-fields/
i'm assuming you realise that you'll need to write code to query db...there are no plugins to query a db (that i know of).
it also sounds like you are going to duplicate data ie pull data from custom table events and shows, then add to this data to custom fields. i'm not sure this is the best approach.
also, if data in these custom tables change, will it be reflected in your custom fields data?
have i assumed too much? let me know.
To query db, use the wp class wpdb. I havent really used it but it has enough features to do what you want.
acf plugin has already been mentioned. custom post type ui plugin is easy for creating custom post types with no code. it even prints out the actual code for you so you can copy it, place in functions.php, then disable plugin, nice.

Categories