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
Related
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.
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.
I am busy converting a HTML website into a Joomla temaplate, I got some help doing the home page (index.php), but now the menu items are not linking anywhere. I have a ready coded AboutUs.php page, which I want to important into Joomla and link to the 'About Us' menu item.
Can this be done in the similar way as it is done with the index.php file? Can I maybe upload the file via FTP and link it somehow in Joomla?
Any help on this would be much appreciated.
No it's not how joomla works.
You have to create the second menu item, link it with your content and add the extra modules that your "about us" page have.
If you don't want to do it like that you could create a new template and link each menu to different template but it's not a good approach.
If you are interested about the html part of the php site,
you can just create an article and paste html code in it (do not forget to set the editor in text mode).
If you have css, you may add it int the template's css file.
Otherwise, if you need php functionality, you need to create a joomla component.
If your going to migrate a site and use a tool like joomla i strongly suggest using it the way it was designed to be used. Otherwise theres no point.
When creating from scratch or migrating a site to joomla i would suggest firstly creating (or modifying) one or more templates to get the layout of you site; header, footer, logo, background, modules (eg. menu, login, etc) and component to load and so on.
You will have to recreate the menu items using the menu manager and apply your css to the menu module(you can download free menu modules or use the default one or develop one).
When creating a menu item you can select the template to be used and also what component you want to load (article, sitemap, blog, login, create user, etc...). An article is used to store html content which can be edited through the content manager although there are simple ways to add scripts to your articles.
If you want to add php to your content you have 4 choices.
Template (used to show content which appears on every page; this is where the html starts and ends and where the component and modules' positions are defined),
Component (this is loaded from the template depending on what menu item is selected),
Module (a very simple and easy way to add custom php and html code, can be loaded from the template or from components like in a joomla article),
Plugin (used when wanting to run scripts which dont have any visual content)
So basically I have a template that I use for every single page besides one page - The gallery page - I want it to look a different way therefore I have to take some of the code out of the .php file, but obviously I don't want to take it out of the index.php because that will affect all the pages then.
My question is basically how do I tell the Gallery page (Menu item) to use this different .php file - gallery.php - Much like how in WordPress you can have different .php files for pages.
I know that you are supposed to use the template manager to "Assign" menu items to different templates but how does it know what file to reference for the separate template. Do you have to create another folder on your server that would contain a different index.php?
No need to create another folder or index.php
All you need is to assign a different template for the menu item for your Gallery page.
Go to Joomla administration, select Menus from the top menu in admin, select the menu where is your gallery based and do the following:
Menu manager -> Edit menu item -> Template style (bottom left dropdown) = you can choose which template you want to use for this menu item.
Hope this helps you!
First it is important to understand how Joomla works. There is only one file in Joomla ever. The framework uses index.php from the current template to create the page being requested. That file basically defines where you can put modules relative to the content that the component is going to display. Joomla knows how to build a page based on the query string of the URL (or variables posted if you have SEF URLs turned on). The URL will tell Joomla what component will be supplying the content, and the itemID of the content.
The component is where the code is different from one page to another. For example, a photo gallery component will have the code to display images while a form component will have the code to display a contact form. Index.php never changes, it just loads the code from the component.
The itemID is the important part of the equation because it is how you can assign different modules to a particular page in the module manager. When you create a menu item for Gallery, it gets assigned a itemID that you can then use to assign various modules or templates to that page. When you create a module (like a login module or menu module) you put it in a position, then assign it to all pages, a selection of pages, of all but a selection of pages.
Generally I don't use multiple templates unless there is a structural difference in the pages. You can just use the page class suffix to assign unique IDs to each menu item so you can then control each page with unique CSS.
I know how to hide the main component from the homepage, what I need is to do the same thing for all my menu items also. Basically, what I want is to create multiple homepages, so every category I choose has certain modules that display content.
How to show only modules, not the article when you click on a menu item (if it is linked to a single article)?
I know I can use some of the extensions that can embed modules to an article, but don't want to do it like that. I know that there are components that simulate homepages, don't want it like that either.
I hope my question is clear enough, I'm using Joomla 1.7.
I have found a simple solution!
Installed T3 framework, which allows the removal of main content component for the menu items you choose.