ImpressPages add pages custom fields - php

I need to add custom fields to a Page.
I created a Plugin that manages the Categories/SubCategories. But now I can't find how can I show the category field on the "Add Page Modal" view without editing the original file inside Ip/Internal/Pages.
As the override folder in themes is only for views is there a way to override/extend internal controllers?
E.g:
- adding multiple tags, categories, etc.
- A widget that filters the pages that have the selected tags (!= alias, because is not unique)
Thanks!

You can definitely add your fields to page details. Check the plugins for examples (this plugin adds it's own section - http://market.impresspages.org/plugins/PageImage).
However, I doubt that you can add fields to a modal. If you really need this, create a feature request on GitHub.

Related

Allow page text to be edited from inside the wordpress menu without hardcoding it

New to WordPress theme design, and my google searching is not returning what I am after.
I have a theme I have created and its fine, but the text is all hardcoded into the theme.
I want there to be options in the theme appearance settings? (right place?) where a user can e.g. enter their 'about us' text.
But I have no idea what I should be searching or how to pull in that information into my theme.
Im no a beginner to PHP, but just the way WordPress works itself.
A link, search term or quick start is all I need.
I think you might find the (Free) Advanced Custom Fields plugin useful: http://www.advancedcustomfields.com/
You can add unlimited custom fields and create user interfaces for non-technical people to add content to your theme without them touching any code.
If you set up a field named 'about_text', calling it in your theme would look like this:
<?php the_field('about_text'); ?>
First, you should learn how wordpress is working to display the content. In back office, under Settings > Reading you'll find an option that let you tell how you want Wordpress to deal with the front page : is it a listing of the posts, or a static page?
If you choose the first options, it will use the index.php template from your theme folder. If it's a static page, you'll have to select which page to use for displaying the home (a page you created under the Menu page). The template that will be use then is front-page.php.
For every post / page (page is a post_type, just a variation of post) there will be a title field, a wysiwyg content and a featured image which will be displayed in a template. That's all you can manage by default. To display the title you can use the_title, the content the_content and for the featured image you will need the_post_thumbnail - note that those functions will need to be used inside the loop.
In order to display some more fun, you have many tools at your disposal:
Widgets : widgets are displayed in a sidebar - don't take it literally, it's just a zone of your template. You can register a sidebar with register_sidebar (use this inside your functions.php file, within an init hook). Then in your template you can display the sidebar with dynamic_sidebar.
In WP back office, go then under Appearence > Widgets. You will find your brand new sidebar where you can put any kind of widget you want. If you need a wysiwyg widget, I recommend you to install the Black Studio TinyMCE widget.
Custom fields : any post_type (a post type is an entry in wp_posts) in Wordpress have some associated metas store in wp_postmeta. A meta is defined by a key and a value - it's like any post have an associated array that you can customize.
There is two ways to work with custom fields. First, you can use the default Wordpress feature: when editing a page, click on the screen options button on the top right and enable "custom fields". You will now have a new area to work with on the bottom of the page : you can add fields by name (by default it will list the existing fields names but you can add your own) and value. It's good enough to simple text fields. Then in your template, you can get that value with the get_post_meta function.
The other way is to use a custom fields plugin, which allow you to have wysiwyg fields, loops, media uploader, datepicker... Two popular plugins are Advanced Custom Fields and Custom Field Suite. They both allow you to easily create set of fields for any page / post_type from the back office, and provide their own functions to manipulate fields in templates (but you can still use the WP functions if you want). For example, to get a custom field with Custom Field Suite you do: CFS()->get('my_custom_field').
Custom Post Types : sometimes, custom fields and widgets are not really convenient when you deal with a lot of data with possibly associated pages. In that cases, you can create your own post types just like posts or pages, but you can define which capabilities they have. Use register_post_type to define your new post type (still in init hook), that will make a new section available in your back office, just like posts. Then in your template you can query them with get_posts, the WP function that you will probably the most use when you'll start to play with Wordpress. I suggest you to read the WP_Query documentation in order to learn more about it.
And, at last but not least, you can create your own template that you can associate with any pages. For that, create a php file named whatever you want in your theme folder, paste into it the content from page.php and add this PHP comment on top :
/*
Template Name: My Template
*/
Then choose this template in the dropdown when you edit a page (on the right sidebar).
I think you will have enough to play with, but if you want learn more I recommend you to read about Wordpress hooks and the Widget API to create your own widgets.
Have fun with Wordpress!

How to make WordPress pages where only certain (multiple) areas of content are editable

It has been a few years since I properly worked with WordPress. Now I have a proposal to build a WordPress site where every page has a custom design and only some areas of each page is editable.
The reason for this is to build a bespoke layout on each page which cannot be messed up by someone non-technical editing it in the CMS, except for small areas which they can customise.
e.g. A page contains one div which has some text in it, which can be edited in the WP admin backend, but the rest of the page cannot be edited.
Can this be done? How?
Edit: There needs to be multiple editable areas not just one. I know how to make custom pages/templates.
One method may be to create new page templates. Just create a new file in your main theme folder (or the templates folder if there is one). As long at the top of that file contains the line:
/*
Template Name: <your template name>
*/
You can design the page however you want. The data pulled from the admin section will go wherever you invoke
the_content();
The rest of the page can be hardcoded.
Then on the post edit page, on the right side (usually), you can choose the template with your template name for that page. It may be a good idea to copy the current post.php or single.php into your custom file and work from there.
For restricting access you can look at setting up user levels and keep your content contributors as "Authors" instead of "admins" so they can't change themes or edit settings.
(See https://codex.wordpress.org/User_Levels)
For creating specific unique pages with an area that gets changed you should look into custom Page Templates. You can create a page template by dropping a php file with the right naming structure into your theme hierarchy and it will get picked up by the back-end as template option when you create a page.
(See https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/)
I solved this problem using a plugin called Advanced Custom Fields which does exactly what I required.

List sibling items in Joomla! K2 item page

How can I display all of the sibling items in a parent category on a Joomla! K2 item page? I want all, not just the next and previous. I, also, want to display additional data like the image and extra fields. I realize the category page does this already, but I need it on the individual item pages, too.
There are two ways, create a plugin or just do it in your item.php template (overriden in your template/html/com_k2/ folder!)
Creating a plugin is the correct way. It requires more effort and and creating a plugin is a deep topic that's been described a thousand times.
The same goal can be reached just by editing the item.php template file, but just be aware that it's not a good practice to connect to the database in a template file. You have to do there the same things as you would do in the plugin except you don't have to create the plugin. You have to access the DB and select your desired data from it. Then, you can just write some HTML where you'll put all the data you want.
These pages might help you with both developing the plugin and editing the template
K2 for Joomla - Part 9: Template Overrides
Example K2 plugin (for developers)
Selecting data using JDatabase - Joomla! Documentation

Unique fields added to Wordpress Pages editor

I need to customise the page editor in Wordpress so I have 5 text fields which I can pull out in the front end page. This is because the Wordpress manager is a bit hopeless with no HTML skills and the content of these boxes will populate buttons and a drop-down select. These fields will be completely unique to the page being edited. How do I go about this? Do I need to build my own plugin or customise an existing one or other?
Advanced Custom Fields is a great plugin for this. You can target a particular page to display fields on and then output your fields in the front end templates using:
the_field('field_name');
See here: http://www.advancedcustomfields.com/

Wordpress - Custom Meta Tags controlled from a custom Plugin

I have recently built a plugin for Wordpress sort of Special Events & News listing. I have a listing page and then a detailed page for every news item. Now in the database I have set up 3 columns named meta_title, meta_description and meta_keywords. I also have All in one SEO plugin installed.
Is there a way how from within the plugin (from the loop where I am showing the content), I can say for example wp_page_meta = $meta_title or something similar?
As I found some tricks on how to do this by hacking the functions.php and header.php for the theme but this is not the right way.
You may want to check out the get_post_meta function in the codex and create custom meta boxes for each event, instead of dealing with the database directly.
http://codex.wordpress.org/Function_Reference/get_post_meta
To add a meta box:
http://codex.wordpress.org/Function_Reference/add_meta_box

Categories