extend contentRenderer Mura - coldfusion

I'm looking to extend the content renderer in a plugin I'm developing so that I can add custom Mura tags to use throughout a website instead of content objects which for the purpose of this plugin are too inflexible.
Firstly, is this the right way to go about it? Am I barking up the wrong tree and there is an easier much more obvious way of doing it without using content objects?
If anyone could help me work this out that would be great.

To add custom mura tags you can use the injectMethod function within your eventhandler.
In the onSiteRequestStart method of your plugins event handler you can use the following function:
<cfset $.getContentRenderer().injectMethod('[mura-tag-key]',[actual-function-to-inject]) />
So if you create a function called getAddress in your event handler you can make it available as a mura tag with the name dspAddress using this code in your onSiteRequestStart:
<cfset $.getContentRenderer().injectMethod('dspAddress',getAddress) />
You can see a real-life example of this in my More dspObjects plugin on GitHub: eventHandler.cfc

Related

Replace Javascript with Bootstrap responsive slideshow

I'm trying to find a nice looking bootstrap slideshow that looks similar to this one: https://www.jssor.com/demos/simple-fade-slideshow.slider
I would use the one in the link but it's got way to much Javascript and doesn't respond properly when I change the size of my window. Any ideas how I could create this using Bootstrap, HTML and CSS only? So it still needs to be automatic as well.
Thank you
It’s the carousel you’re after, without knowing which version of bootstrap you’re on I cannot provide an example but you can find full examples for what you need in the bootstrap docs: https://getbootstrap.com/docs/4.1/components/carousel/

use poll package in umbraco website

I'M using umbraco CMS and i want to add or make poll in my website..
After searching for package i found this one POLL PACKAGE FOR UMBRACO 4 which you can get it from umbraco site here . The problem here is that to use it i should insert the macro by myself(the developer) and give it the poll id(which was created by the client).
i want to make this dynamically maybe by using XSLT but the macro is .net UserControl.
if someone used it before give me some idea.
Here's an option:
You can create another document type, in the template of which you load the macro. You can populate the macro parameters based on the properties that are selected on the node of the document type you created using the Advanced macro parameter syntax.
For example, you have a Content picker on the document type and you fill the macro with the id of the node that is chosen. In the master page you would do the following:
<umbraco:Macro Alias="Poll" runat="server" PollNodeId="[#nodeId]" />

make changes outside angularjs view

i'm using Angular's Routeprovider together with ngView to make my webapp. However, the ng-view is a div inside the body of the page, but when the curent route changes, I'd also like to change the title tag, and possibly some meta tags. What would be the best way to do this? Attach another ng-controller to the html tag, and control content of title and meta tags from there using the $location service? Or is there a better way?
Well This can be done easily. Without giving you the code, i'm sharing already given solution's link. http://www.bennadel.com/blog/2425-Decorating-Scope-Methods-In-The-AngularJS-Prototype-Chain.htm

How can liferay template show page specific info

I need to make some parts in template show or hide based on what page i'm on. I know I can make multiple themes in liferay-look-and-feel.xml file and give settings but this creates multiple themes in admin.
Is there some other way like accessing info about what portlets are on this page. Lets say if it has log in portlet then don't show navigation links for example?
I think the simple way is to add this function over javascript. With javascript you can e.g. observe existing of login-portlet-id and then hide the navigation.
In liferay template, a velocity variable is available called the $processor. It is nothing but object of
com.liferay.portlet.layoutconfiguration.util.velocity.TemplateProcessor
The portletId is available in this object, but there is no direct method to get it. Please have a look at:
TemplateProcessor.java.html
Once you get the portletId, then you can write the logic to hide certain sections.

Are there any good tutorials for using sitemesh in a grails application?

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.