i am very confused right now. I came from Wordpress,and laravel frameworks, and now i am assigned to develop Joomla! project.I thought i can easily manage to create custom template in joomla. I have been reading a lot of articles and documentation. I've manage to create a template and display modules.
But now, i need to start digging the right way to display the content and manage it in Joomla! back-end.
Here's my problem. I have home page (Long page) and inner pages (Short page). Here's the structure of my homepage
<html>
... header links and other necessary tags
<body>
<section class="homepageonlysection1">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section >
<section class="homepageonlysection2">
<div>
form here (i made this as 1 modules in Custom HTML)
</div>
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
</section>
<section class="homepageonlysection3">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
and this is my inner pages
<html>
... header links and other necessary tags
<body>
<section class="innerpagessectiononly1">
<div>
Article Content (i will do as jdoc:inlucde type="component")
</div>
</section>
<section class="innerpagessectiononly2">
<div>
sidebar Content (i will do this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
Those template are really different.
Problem 1 : How can i make my inner pages if my homepage structure is very different? Or
Problem 2 :How can i make display my section (homepageonlysection) in home page only and display (innerpagessectiononly) in inner pages only?
Problem 3 : Is there a Advance Custom Field (ACF for wordpress) as joomla extension ?
Please advice. Any help would be appreciated.
One thing I recommend is really digging into the core templates (both front and backend) to understand how things work. In particular Isis the backend template illustrates a number of complex options.
Now, overall I think you probably do not want to do the homepage the way you are doing it, since it will be very inflexible and hard to change. On the other hand it's possible that you want it inflexible and hard to change. In reality you may not need to have separate layouts at all or the differences may be minimal and may not require any special code at all.
So, first, this document explains how to determine if you are on the home page. So you can clearly pretty easily test for that and then enclose your two separate designs in the true and false conditions. This is basically what you see in Isis. In your case you can place one or more module position inside the condition. In fact you could make it so this layout does not even load a component. Then you can just make an empty article and make the home page a single article link to that empty article. (I would put that article into a separate landing page category)
A second option if you really want to have a totally different design on the home page is to make a totally separate template for the home page. If say you called this "my home template" and your other template "my everywhere else template" what you could do is make "my everywhere else template" the default and then on the default (homepage) menu item assign the "my home template" template. In this special template you can even use the module jdoc:include (instead of modules) to call specific modules in highly customized ways. I would suggest you go read the docs on that. You can even set the options and the chrome right in the template.
However, I think you are missing a key feature of Joomla. In your question you have not said what kind of menu link you are planning to use for your home page. The third option is that for the homepage you use the same template but a specific alternate layout that you use for this page. For your case what you would most likely want to do, assuming that you are not using the featured articles layout type anywhere else (i.e. that no articles are marked featured), is to make your homepage using an articles > featured menu link. Then you can assign all the modules you made to the home page via the menu modules tab. Depending on how your module positions are in the template it could just be that they will float up.
Your design is not a particularly unusual or complex however. Many Joomla homepages consist of multiple structured sections of text and media. These are made with menu types such as "featured" and "category blog." The advantage of using these menu types is that then you are storing your content in articles and these are much easier to manage. ALso you don't have to give someone access to the module manager in order to allow them to edit these snippets of content. So the fourth and possibly best approach is to use one of these standard content layouts. For example if you were to make a category called "home page content" and then put the content for each of the modules in a separate article and (assuming you want a consistent structure) put the image for each of them into the structured intro text image field, you can then make a "category blog" menu link to the "home page content" category as you default (home page) menu link. Then what you can do is make one or more layout override for those individual items that gives the exact layout you want. Assuming that they are all the same, you can select that as a alternate layout in your menu link. Actually even if they are not all the same you can just do a more complex layout instead of looping through the list and doing the same thing for each article, do each one separately.
A fifth approach is to use an alternative layout instead of an alternate layout. The difference there is that you would give the layout a new name (in either the category or featured view) and then you will have the additional flexibility of being able to create options in the menu link that are different than those for the normal category/featured views. It's up to you to decide what you might want to add there.
There are other options as well, because Joomla has a very strong template community and they like to have a lot of flexibility. But that will get you started.
Related
I need to replace same plugin template on different subpages - e.g. on frontpage I need specific slider template for latest articles, in detail article I need small list, on search result without images etc.
[note: everything about aldryn newsblog app - I don't mean my own plugin!]
*(something like custom template per plugin instance)
How to replace it ? Extending template is not quite what I need - inheritance is from bottom - from lower subtemplate to base.html - but that plugin have hardcoded lower template.
Tons of IF block in template is irrational then we think in MVC.
*( like here Render Django-CMS plugins differently on different splaceholders/templates )
Or maybe just write custom template with using hardcoded including plugins ? But using django cms placeholder editor is very useful and it'll be better to keep working in that way :///
So, I create front.html base template for frontpage,
put some plugins to placeholders - and need to replace subtemplates for this plugins only in this front.html and keep subtemplates for that plugin in other places - this is main goal.
It will be the best, when django cms / aldryn newsblog provide option "custom template" per plugin instance :|
( like this one http://www.ilian.io/django-cms-plugins-with-selectable-template/ )
If I understand your question correctly (it's late here), you need a way to override plugin templates on a plugin instance basis because hacking django templates is not the way to go (I agree).
Django CMS does allow you to override plugin templates on an instance basis.
As shown in http://docs.django-cms.org/en/develop/how_to/custom_plugins.html?highlight=get_render_template#the-simplest-plugin
In your CMSPluginBase subclass add the following:
def get_render_template(self, context, instance, placeholder):
# criteria goes here
return 'sometemplate.html'
As far as how to know which template to render when (criteria), you can do a few things.
Use the page's reverse id:
page = instance.page
templates = {
'homepage': 'plugin_home.html',
'about': 'plugin_about.html',
'contact': 'plugin_contact.html',
}
return templates[plugin.page.reverse_id]
This approach has a few drawbacks:
Relies on plugin being bound to a page. (plugins can live outside of pages)
Can only work with pages that have reverse id set and reverse ids
are unique per page which means you would have to list reverse id
for every page you want to change template for.
Use a page extension to set a category per page:
Checkout http://docs.django-cms.org/en/develop/how_to/extending_page_title.html
With this approach you can then set some sort of category to multiple pages and so you can target multiple pages in one shot like so:
page = instance.page
extension = get_page_extension(page) # Check out docs for this
templates = {
'category_1': 'plugin_category_1.html',
'category_2': 'plugin_category_2.html',
'category_3': 'plugin_category_3.html',
}
return templates[extension.category.name]
Pros:
Can target multiple pages in one shot
Cons:
Relies on plugin being bound to a page.
A bit more complex
Use a template context variable:
In your templates, depending on how you're rendering your plugins, you can
provide a context variable like so:
{% with category='category_1' %}
{% placeholder 'content' %}
{% endwith %}
or
{% with category='category_1' %}
{% render_plugin yourplugin %}
{% endwith %}
Then in your get_render_template method you can access this context variable and do the following:
# Use .get() to provide fallback
category = context['category']
templates = {
'category_1': 'plugin_category_1.html',
'category_2': 'plugin_category_2.html',
'category_3': 'plugin_category_3.html',
}
return templates[category]
Pros:
No extra models.
Can target multiple pages in one shot.
Cons:
The only one I can think of is these random {% with %} in
templates.
I completely missed the newblog part, so in order to override the newsblog plugins or any plugin, just subclass the plugin class you want to override and unregister the original and then register yours, make sure yours has the same class name.
Maybe you can make the whole template logic above into a mixin to use throughout your project.
I've always wanted to give Zinnia a look, but I'm too far into working with NewsBlog on a site right now to do it (and blogs have already been posted and whatnot). You can always just add a few extra placeholders in the template (it's not the most efficient looking thing ever, but it's no load on the framework if you add a placeholder and leave it blank), that way they aren't static, and then you can put whatever plugins you want to inside of them. You can customize each component in NewsBlog pretty easily by just adding whatever you want in the structure mode. Things get trickier when it comes to having multiple blogs that act differently, but even then, as long as you're not adding components into the static placeholders provided by NewsBlog (or as I so elegantly learned it, "don't put the stuff in the blocky-things with the pins next to them), you can create different namespace for the different blogs (either in the admin, under "Configs" in the NewsBlog section, or when creating a new page and hooking it to the NewsBlog app), and you can have different templates on different blogs.
EDIT: This is a really excellent resource for touching up NewBlog without throwing the baby out with the bathwater (after three months of learning DjangoCMS, I'm still finding myself referencing it for fine-tuning pieces of NewsBlog, and to refresh my grasp on templatetags and other things that are overwhelming and have quickly left my brain along the way): https://www.django-cms.org/en/blog/2016/02/16/build-a-website-without-knowing-python-django-part-two/
*I linked to part two, as the first part deals with how to initially setup a project, and I assumed it probably wasn't relevant. Then again, if you're using Aldryn, there are some useful bits in there that can extrapolate if you're having trouble with customizing the boilerplate (or other things you'd like to configure that an Aldryn setup handles for you -- which is super awesome most of the times, but when it's not super awesome, it's usually super frustrating :)
I'm having a hard time coming up with a solution for this problem.
I'm building a WYSIWYG designer, for micro sites. The templates for these microsites will be supplied by an intermediate user, and the end-user will manipulate these templates. So, there are really two groups of users of the app: template-buiders, and end-users. Think MailChimp.
This means my Ember app will start off with a template from a template-builder, say
<h1>An awesome product</h1>
<h2 contenteditable="true">Subtitle away</h2>
<p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>
and the end user, having chosen this template, will then be able to customize it. There are a few requirements:
There will be static, uneditable portions of the page (h1 above)
There will be static, editable portions of the page (h2 above)
There will be options that affect the layout, style, etc. (p above)
So far, my attempts have lead me to build a handlebars helper that takes a string and a context, and returns a rendered template. This is because the above template will actually be coming over from a database, as a string - remember, it's user-generated.
That means, in my application's template, it would look like
<div class="preview">
{{preview-userTemplate template context}}}
</div>
where
template: '<h1>An awesome product</h1><h2 contenteditable="true">Subtitle away</h2><p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>',
context: {optionA: true}
Now, this actually works, in the sense that it will update if context is updated, so I can add controls along the sides for the end-user to manipulate those options. So I have those (more of less) under control.
It's the WYSIWYG content editing that is giving me trouble. In the above template (from my template-builder users), I want them to be able to add contenteditable="true" to places in their templates where the end-users can change the content.
Now, these changes need to be saved. Ideally, I would be able to retrieve the instance view's template back from the DOM, after the inline edits have been made. Is this possible? The original {{data}} placeholder would need to be preserved.
Alternatively, I could make a view/component, so the template-builder would do something like this:
<h1>An awesome product</h1>
{{#editable}}
<h2>Subtitle away</h2>
{{/editable}}
<p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>
but this seems like it would require a good deal of finagling to get the edits to stick - I'm not even sure right now how I'd go about it.
What do you guys think? Is there an easier solution that I'm overlooking? Thanks for any pointers!
I'm working on a Liferay 6 project, and part of the project is to create a new layout template to be used for the entire site as the default. Liferay's own wiki is very sparse on documentation about layout templates, and I haven't had better luck with Google searches or even here on SO.
I did find one article ( Liferay - Layout for each pages ) that sort of answers the question, but it seems like it might be overkill. In that question, the goal was to change the template based on the page, so the answer was to create a Hook and use that to set the template on the fly as needed. Here, I just want to have this custom template be the default for all pages, all the time, which is why I think the answer to that other question might be more than is really needed.
If anyone has the answer to this puzzler, please let me know. Thanks!
-- JLM --
OK, I've figured out my confusion. Liferay has two types of layout templates -- templates that are part of a theme, which is one type of Liferay project, as well as actual layout template projects themselves.
The templates in a theme are where you set up the overall page layout for the site. The main page template, named portal_normal.vm, is a full web page with an <html> tag, a <head> and <body>, etc. Other templates in the theme are usually page fragments.
A Layout Template, on the other hand, is only for laying out the portlets in the main content region of your page (which is defined by tags in your Theme's template files). It is always a fragment and can only have <div> elements or a <table> for laying out the portlets.
Fortunately, this actually makes answering my question very easy, at least in the context that I needed. Per Liferay's documentation at http://www.liferay.com/community/wiki/-/wiki/Main/How+To+Change+Liferay+Default+Theme :
Note: As of 6.x, you cannot just use the theme id specified in the liferay-look-and-feel.xml. Instead, go to Control Panel->Plugins Configuration->Click on theme of interest->note the Plugin ID and use that [as the value for default.theme.id in portal-ext.properties]
I hope this helps some other people trying to figure this out!
When doing larger sites in "big business", you most probalbly work in a team with several developers.
Let's say dev A makes a form to insert new user data, B creates a user list, C makes some privilege administration and D does crazy statistic graphs work with image generation and so on.
Each dev begins to develop his own component, creates a view and a template and tests that independently, until each component works.
Now, the client wants to have all those components on one bit HTML page. How to achieve this?
How to assemble different views/templates in a form of composition so that they remain modular and can be developed and tested independently?
It seems inheritance is not the way to go because all of those UI components are equal and there is no hierarchy.
The idea of the assembling template is something like
<html>
<head>
// include the css for the components and their assembly
</head>
<body>
// include user data form here
<some containers, images, and so on>
// show user list
// show privilege administration in this part
// and finally, the nice statistic graphs
// perhaps, we want to display some other components here in future
</body>
</html>
I have not found an answer on the net yet.
Most people come up with one big template which just implements all of the UI functionality, removing all modularity. Each component shall have its own template and view dealing only with that component developed by one person each, and they then shall be sticked together just like bricks.
I would highly appreciate any hints!
Inclusion tags are the way to do this. Each application defines tags which render their own template fragments, then the master template can assemble them into a single page.
I'm a pretty experienced Grails developer, but most of my experience has been with using grails for serving up JSON/XML to a flex app and some relatively simple HTML websites.
I've been diving deeper into using the sitemesh integration in grails and I'm struggling a little to find best practices for some more complex configurations, and I'm curious if there are any good tutorials or examples out there. The original Sitemesh website isn't that useful as the tags it talks about aren't directly exposed in grails.
A google search is mostly showing old mailing list posts and some vanilla sitemesh stuff which is helping me to move a little further along, but it's a lot of trial and error.
I fully understand how the basic g:layoutTitle, g:layoutHead, and g:layoutBody tags work. Those are easy and well documented.
The kinds of things that I'd like to see examples for:
g:applyLayout - the documentation on this is weak and I don't fully understand the uses suggested in the main docs. How is this different than setting the meta name='layout' content='foo' property?
g:pageProperty - some better examples on how to pull and use properties into the main template by setting the values as meta tags in the page that's being decorated. The grails docs on pageProperty show only the onload attribute from the body being brought forward. I think you can also use meta tag values here as well, anything else?
can you use multiple levels of sitemesh layouts? My testing seems to make me think that I can't, but that seems to reduce reusability. I think that the answer here is some usage of the g:applyLayout, but that's where I'm struggling the most.
the g:pageProperty is a very powerful, but very poorly documented thing. Lets say in my layout I specify where to put some content like this:
<html>
<body>
<g:pageProperty name="page.header" />
</body>
Now in my page I can specify some content:
<content tag="header">
<!-- header -->
</content>
Sitemesh will take the content tag, regardless of actual position in the HTML of the page and place it where it needs to go in the flow of the layout.
Even better, if within my page I render a template that also specifies a content area with a tag of "header", it will overwrite the first declaration, and it will be the template's content that will be rendered in the final layout.
Well, I can answer a bit:
Your first and third questions are related, as you can't chain layouts using the meta tag.
Your final page should have a meta tag as you suggest, but if you want to layer a layout on top of another layout, you put a g:applyLayout tag at the top of the child layout, pointing at the parent.
In your edit.gsp, you'd have:
<meta name="layout" content="editTemplate" />
and in editTemplate.gsp, you'd have:
<g:applyLayout name="baseTemplate" >
<!-- the html for the editTemplate -->
</g:applyLayout>
so edit.gsp would use editTemplate.gsp, which would use baseTemplate.gsp as a base layout. You can chain those as needed.
I haven't used g:pageProperty at all, so I can't throw you better examples there, sorry.
The Sitemesh together with Grails is a very very powerful feature. The more I use it - the more I love it. You can decorate any part of our web site: you can have layout for error messages, tooltips, news lines, comments, etc, etc. Just to note that you can do even that with in your pages and have multiple levels of decoration (no <content> needed):
/view/layout/inline-error-message.gsp
<span class="errorMessageInSomeFancyBox">
<span class="errorIcon"></span>
<g:layoutBody />
<span>
/views/book/create.gsp
<%-- let's decorate our error message with some fancy box --%>
<g:applyLayout name="inline-error-message">${some.error.message}</g:applyLayout>
See our Rabbtor Showcase App for a few very good examples on
creating nested layouts
rendering templates
applying layouts to specific parts of a page
. This app is actually a showcase for our tool Rabbtor which enables using GSP outside Grails but parts related with Sitmesh are also valid for Grails.