These are the most important models:
Note: To use methods prefixed by the_ you will need to decorate the object like this: my_model = my_model.decorate
Sample:
post10 = current_site.the_post(10).decorate
puts post10.the_title
More information about models and queries here.
| User | |
| the_id | return the identifier |
| the_name | return the full name |
| the_avatar | return the avatar for this user, default: assets/admin/img/no_image.jpg |
| the_slogan | return the slogan for this user, default: Hello World |
| the_contents | return all contents created by this user in current site |
| the_username | return the username of this user |
| the_role | return the role of this user |
| the_url(url_params) | Return the public url for this object using current locale and extra vars passed. as_path: (boolean) return the path instead full url, locale: custom locale my_user.the_url(my_var: 'one', locale: "gp") ==> https://my_site/profile/1-my.name.html?my_var=one |
| User administration | |
| my_site.users.where(role: "admin") | select all users with role admin |
| my_site.users.create({email: 'admin@local.com', username: 'admin', password: 'admin', password_confirmation: 'admin' }) | Create a new user for my_site |
| my_site.users.where(username: "admin").first | Select the user with username = admin |
| my_site.users.where(username: "admin").first.destroy | destroy the user |
| my_user.admin? | check if this user is an administrator |
| my_user.get_role(site) | return the role of this user for site |
| my_user.assign_site(site) | assign this user for site |
| Configurations and custom fields here | |
| Category | |
| the_id | return the identifier |
| the_title | return the title for current locale (language) |
| the_slug | return the slug for current locale |
| the_content | return the description for current locale |
| the_excerpt(qty_chars = 200) | return excerpt for this post type. qty_chars: total or characters maximum |
| the_posts() | return all posts contents for this category (active_record) filtered by permissions + hidden posts + roles + etc... in return object, you can add custom where's or pagination like here: https://edgeguides.rubyonrails.org/active_record_querying.html |
| the_post(slug_or_id) | search a post with id (integer) or slug (string) |
| the_url(url_params) |
Return the public url for this object using current locale and extra vars passed. |
| the_categories | Return children categories |
| the_category(slug_or_id) | return a child category from this category with id (integer) or by slug (string) |
| generate_breadcrumb(add_post_type = true, is_parent = false) | add_post_type: true/false to include post type link is_parent: true/false (internal control) |
| the_thumb_url(default: nil) | return thumbnail for this post type default: if thumbnail is not present, will render default |
| the_breadcrumb(add_post_type = true) | draw breadcrumb for this model add_post_type: true/false to include post type link |
| set_decoration_locale(locale) | Set a new locale for current model, sample: set_decoration_locale(:en) |
| the_created_at(format = 'long') | return created at date formatted |
| the_keywords | return the keywords for this model |
| Category administration | |
| the_edit_url | Return the edit url |
| my_post_type.categories.create({name: 'My Category', slug: 'my_category', parent: model_posttype_or_category.id}) |
Create a new category for my_post_type with slug: "my_category". parent: id of a category or a post_type |
| my_posttype.the_category(slug_or_id).destroy | destroy a category from this post_type with id (integer) or by slug (string) |
| Configurations and custom fields here | |
| Post | |
| the_id | return the identifier |
| the_title | return the title for current locale (language) |
| the_slug | return the slug for current locale |
| the_excerpt(qty_chars = 200) | return excerpt for this post type qty_chars: total or characters maximum |
| the_content | return the content for current locale + shortcodes executed |
| the_thumb_url(default = nil) | return thumbnail image for this post default: default image if thumbails not exist if default is empty, post_type default thumb will be returned |
| the_breadcrumb(add_post_type = true) | draw breadcrumb for this model add_post_type: true/false to include post type link |
| set_decoration_locale(locale) | Set a new locale for current model, sample: set_decoration_locale(:en) |
| the_created_at(format = 'long') | return created at date formatted |
| the_keywords | return the keywords for this model |
| the_url(url_params) | Return the public url for this object using current locale and extra vars passed. as_path: (boolean) return the path instead full url, locale: custom locale my_post.the_url(my_var: 'one', locale: "gp") ==> https://my_site/gp/mypost/?my_var=one |
| has_thumb? | Check if current content has uploaded a thumbnail image |
| the_thumb(img_args = {}) | show thumbnail image as html |
| the_link_thumb(link_args = {}, img_args = {}) | show link and thumbnail included as html, link_args: html attributes for link, img_args: html attributes for image |
| the_categories | return all categories assigned for this post filtered by permissions + hidden posts + roles + etc... |
| the_tags | return all post_tags assigned for this post |
| the_comments | return all main comments approved, not include answers |
| can_visit? | check if the content can be visited |
| can_commented? | check if the content permit create comments |
| the_post_type | return the parent post_type model |
| the_field_content(field_key) | return custom field content with key field_key, translated and short codes evaluated like the content |
| Post administration | |
| my_post_type.posts.create({title: title, slug: slug, content: content, user_id: user.id, status: 'published'}) |
Create a new post with status published |
| my_post_type.the_post("my_post").destroy | destroy the post with slug = my_post |
| mypost.template | return template assigned to this post |
| mypost.published? mypost.pending? mypost.draft? mypost.trash? |
Check post status |
| mypost.author | return User owner of this post |
| Configurations and custom fields here | |
| PostType | |
| the_id | return the identifier |
| the_title | return the title for current locale (language) |
| the_slug | return the slug for current locale |
| the_content | return the description for current locale |
| the_excerpt(qty_chars = 200) | return excerpt for this post type. qty_chars: total or characters maximum |
| the_posts | return all posts contents for this category (active_record) filtered by permissions + hidden posts + roles + etc... in return object, you can add custom where's or pagination like here: https://edgeguides.rubyonrails.org/active_record_querying.html |
| the_post(slug_or_id) | search a post with id (integer) or slug (string) |
| the_url(url_params) | Return the public url for this object using current locale and extra vars passed. as_path: (boolean) return the path instead full url, locale: custom locale my_post.the_url(my_var: 'one', locale: "gp") ==> https://my_site/gp/mypost/?my_var=one |
| the_breadcrumb(add_post_type = true) | draw breadcrumb for this model, add_post_type: true/false to include post type link |
| set_decoration_locale(locale) | Set a new locale for current model, sample: set_decoration_locale(:en) |
| the_created_at(format = 'long') | return created at date formatted |
| the_keywords | return the keywords for this model |
| the_categories | return all main categories of current post_type |
| the_post_tags | return all post_tags for the post_type (active_record) filtered by permissions + hidden posts + roles + etc... in return object, you can add custom where's or pagination like here: https://edgeguides.rubyonrails.org/active_record_querying.html |
| the_thumb_url(default = nil) | return thumbnail for this post type default: if thumbnail is not present, will render default |
| posttype administration | |
| add_post(args) | add a post for current model, where args include: tilte: title for post, => required content: html text content, => required thumb: image url, => default (empty). check here for uploads. has_comments: 0|1, => default (0) categories: [1,3,4,5], => default (empty) tags: String comma separated, => default (empty) slug: string key for post, => default (empty) summary: String resume (optional)} => default (empty) return created post object if it was created, else return array of errors |
| the_edit_url | Return the edit url for this object |
| current_site.the_post_type("layout").present? | check if a post is already registered. return true/false |
|
pt = current_site.post_types.create(name: "Home Layout", slug: "layout") |
Create a new post type for current site. my_post_type.set_settings({has_category: false, has_tags: false, .......}) #set multiple settings Available options are: {has_category: false, has_tags: false, has_summary: false, has_content: true, has_comments: false, has_picture: false, has_template: false, has_keywords: false} |
|
current_site.the_post_type("layout").destroy |
delete a post_type from current site |
|
ptype.manage_categories? |
Check if this post type can manage categories |
| ptype.manage_tags? | Check if this post type can manage tags |
| ptype.set_settings({}) | Set settings for this post type Available settings: {has_category: false, has_tags: false, has_summary: true, has_content: true, has_comments: false, has_picture: true, has_template: false, has_keywords: true} |
| ptype.set_setting(key, value) | Set or update a setting for this post type |
| ptype.ful_categories | Return all categories (include children) from this post type |
| ptype.show_for_admin_menu? | Check if this post type is listed on admin -> contents -> menu |
| ptype.toggle_show_for_admin_menu(flag) | Hide or Show this post type on admin -> contents -> menu true => enable, false => disable |
| Configurations and custom fields here | |
| PostTag | return the title for current locale (language) |
| the_id | return the identifier |
| the_title | return the title for current locale (language) |
| the_slug | return the slug for current locale |
| the_content | return the description for current locale |
| the_excerpt(qty_chars = 200) | return excerpt for this post type, qty_chars: total or characters maximum |
| the_posts | return all posts contents for this category (active_record) filtered by permissions + hidden posts + roles + etc... in return object, you can add custom where's or pagination like here: https://edgeguides.rubyonrails.org/active_record_querying.html |
| the_post(slug_or_id) | search a post with id (integer) or slug (string) |
| the_url(url-params) |
Return the public url for this object using current locale and extra vars passed. |
| the_breadcrumb(add_post_type = true) | draw breadcrumb for this model, add_post_type: true/false to include post type link |
| set_decoration_locale(locale) | Set a new locale for current model, sample: set_decoration_locale(:en) |
| the_created_at(format = 'long') | return created at date formatted (long|short) |
| the_keywords | return the keywords for this model |
| the_edit_url | Return the edit url for this object |
| Configurations and custom fields here | |
| Site | |
| the_id | return the identifier |
| the_title | return the title for current locale (language) |
| the_slug | return the slug for current locale |
| the_content | return the description for current locale |
| the_excerpt(qty_chars = 200) | return excerpt for this post type, qty_chars: total or characters maximum |
| the_posts(slug_or_id = nil) | return all contents for this site registered for post_type = slug (filter visibility, hidden, expired, ...) slug_or_id: slug (string) or id(integer) of the post_type if slug is not present, then this will return all posts for this site |
| the_post(slug_or_id) | search a post with id (integer) or slug (string) from this site |
| the_url(locale = nil, as_path = true) | return the public url for current locale, as_path: true => return the path and not full url, locale: nil => return current locale |
| the_breadcrumb(add_post_type = true) | draw breadcrumb for this model, add_post_type: true/false to include post type link |
| set_decoration_locale(locale) | Set a new locale for current model, sample: set_decoration_locale(:en) |
| the_created_at | return created at date formatted |
| the_keywords | return the keywords for this model |
| the_logo | |
| the_icon | |
| the_contents(slug_or_id='post') | return all contents from this site registered for post_type = slug_or_id (filter visibility, hidden, expired, ...) slug_or_id: slug (string) or id(integer) of the post_type, default 'post' |
| the_category(slug_or_id) | return the category with id or slug from this site slug_or_id: slug (string) or id(integer) of the category |
| the_categories | return all main categories |
| the_full_categories | return all categories |
| the_tags | return all tags |
| the_post_types | return all post types |
| the_post_type(slug) | return the post type with slug = slug |
| draw_languages(list_class = "language_list list-inline pull-right", current_page = false) |
draw languages configured for this site |
| the_languages | return Array of languages configured for this site |
| visitor_role | return the role_id of current visitor for this site, if the visitor was not logged in, then return -1 |
| get_plugin(plugin_slug) | return plugin model with slug plugin_slug |
| plugin_installed?(plugin_key) | check if plugin_key is already installed for this site |
| get_theme(theme_slug = nil) | return theme model with slug theme_slug for this site theme_slug: (optional) if it is null, this will return current theme for this site |
| the_admin_url | Return the admin root url for this site |
| the_edit_url | Return edit url for this Site |
| Site administration | |
| site = Site.create(name: "My Site", slug: "my_site") | create a new site |
| site.destroy | destroy site |
| site.users | return all users assigned to this site (Check config/system.json to configure share users between sites) |
| site.nav_menus | nav menus collection registered on this site |
| site.widgets | return all widgets registered for this site |
| site.sidebars | return all sidebars registered for this site |
| site.user_roles | return all user roles registered for this site |
| site.custom_field_groups | return all custom field groups registered on this site |
| site.plugins.active | return all plugins installed for this site |
| site.set_admin_language(lang) | set the language for admin panel |
| site.get_admin_language | return current admin language configured |
| site.main_site? | check if this site is the primary site (first site) |
| Configurations and custom fields here | |
| Theme | |
| the_id | |
| settings | return a Hash with config.json values |
| Configurations and custom fields here | |
| Plugin | |
| active? | check if current plugin is installed |
| installed_version | return the installed version of current plugin |
| old_version? | verify if installed version is equal to current plugin files |
| settings | return a Hash with config.json values |
| Configurations and custom fields here | |
| PostComment | |
| the_created_at(format= :long) | return created at date formatted |
| the_user | return user model (owner) of this comment |
| is_approved? | Check if current comment was approved. |
| Configurations and custom fields here | |
| Widget | |
| current_site.widgets.create(params) |
Create a new widget: {title: "my widget title", slug: "my_widget_slug", description: "my descr"} |
| the_title | |
| the_content | |
| render | Render the widget with its template |
| Configurations and custom fields here | All custom fields assigned to a widget, this will be shown on sidebar editor |
| Sidebar | |
| current_site.sidebars.create(params) | Create a new sidebar: {title: "my sidebar title", slug: "my_sidebar_slug", description: "my descr", render_file: "render_file_path"} |
| add_widget(widget, data = {}) |
Add or update a widget assigned into this sidebar. assign the widget into this sidebar, widget: string(slug)/object, data: {title, content}. Return Assing_widget. To this result you can do: Assing_widget.set_field_values(params[:field_options]) |
| get_widgets | return all widgets assigned from this sidebar |
| get_widget(slug_widget) | get specific widget assigned from this sidebar |
| destroy_widget(slug_widget) | destroy the widget assigned from this sidebar |
| Configurations and custom fields here | |
| NavMenu | |
| current_site.nav_menus.create (name: "My menu", slug: "left_main_menu") |
Create a new menu and return a NavMenu model |
| Configurations and custom fields here |