How to override popup.pt in Plone? - overriding

I was able to modify the original popup.pt and see changes in my instance, but when I try to override it by copying and renaming to archetypes.referencebrowserwidget.browser.popup.pt in my theme/(add-in) overrides folder I am unable to see my changes.
I overrode the path_bar class viewlet, following this tutorial. I attempted to follow the same logic for overriding popup.pt, but I was unable to get Plone to see the file in my configure.zcml.
configure.zcml:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="mytheme.theme">
<includeDependencies package="." />
<plone:static
directory="resources"
type="theme"
/>
<genericsetup:registerProfile
name="default"
title="mytheme.theme"
directory="profiles/default"
description="Installs the mytheme.theme package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<browser:viewlet
name="plone.path_bar"
manager="plone.app.layout.viewlets.interfaces.IAboveContent"
class=".customizations.PathBarViewlet"
permission="zope2.View"
layer=".interfaces.IMyTheme"
/>
<browser:page
name="login_main_template"
for="*"
permission="zope.Public"
template="login_main_template.pt"
/>
</configure>
While searching for a solution I found this Stackoverflow question - How to customize the popup.pt template from archetypes.referencebrowserwidget?. I added/:
<include package="z3c.jbot" file="meta.zcml" />
<browser:jbot directory="jbot_templates" layer=".browser.interfaces.IThemeSpecific" />
to my configure.zcml and removed the browser:viewlet from my previous attempt but I was still unable to get Plone to see my overview.
Which method do I need to use to override, the class viewlet, the z3c.jbot, or just the standard copy/rename method? I have read thru the Plone documentation multiple times, but still unable to resolve my issue. If I need to post any additional files please let me know.
Thanks in advance.

The z3c.jbot approach usually just works fine.
You have to be sure, that the file you place into to your jbot_templates folder has the right name.
The path to the popup.pt is archetypes/referencebrowserwidget/browser/popup.pt,
So in your case the filename must be archetypes.referencebrowserwidget.browser.popup.pt
Please make sure that your browserlayer .interfaces.IMyTheme is active on your site -> browserlayer.xml

Related

How to deliver static html with plone.app.theming

I use Diazo to deploy the static html-file 'ticker.html' on a certain url. That page uses nothing at all from the content.
This is the rules.xml:
<rules xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<rules if-path="/Plone/ticker/ /ticker/">
<theme href="ticker.html" />
</rules>
<rules css:if-content="#visual-portal-wrapper" if-not-path="/Plone/ticker/ /ticker/">
<theme href="index.html" />
The rest of the theme...
</rules>
</rules>
It works fine and the html is correct but the return-code of http://localhost:8080/Plone/ticker is 404. Only if I create some dummy content in Plone at this location I get a 200. The returned is also slightly changed: When there is a dummy content Diazo adds a base-tag to the header:
<base href="http://localhost:8080/Plone/ticker/" />
How can I tell Diazo to completely ignore the content and return a 200 even when there is no dummy-content?
In case you are wondering: I use Diazo for this because plone.app.themeing allows to modify the static page through the web.
The plone.app.theming transformation is the last step in the delivery pipeline. The content has already been summoned from Plone so that it can be combined with the theme. So, it's not the appropriate place to do this.
Instead, do this with the rewrite rules of your reverse proxy. Have the proxy fetch your ticker whenever it receives a request for the target URL. You'll also save a lot of CPU cycles in the process, since you'll avoid the whole trip through Zope/Plone's machinery.
I had a similar usecase where i want to server some js-partials through Zope to AngularJS. They are text/html so they got transformed through plone.app.theming. After a deep look into plone.app.theming i overloaded the ThemeTranform adapter with a subclassed one in a new file transforms.py as shown below:
# -*- coding: utf-8 -*-
from plone.app.theming import transform
from your.theme.interfaces import IYourThemeLayer
from zope.component import adapter
from zope.interface import Interface
#adapter(Interface, IYourThemeLayer
class ThemeTransform(transform.ThemeTransform):
def parseTree(self, result):
# Prevent diazo from adding doctype and html head to every
# html file. Exclude all partial resources from theme transforms
if '/++resource++your.theme.js-partials/' in self.request.getURL():
return None
return super(ThemeTransform, self).parseTree(result)
... and register in zcml to the same name as the default ThemeTransform adapter using:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="your.theme">
<!-- Override plone.app.theming adapter -->
<adapter
name="plone.app.theming.transform"
factory=".transform.ThemeTransform"
zcml:condition="installed plone.app.theming"
/>
</configure>
May be related to this issue: https://dev.plone.org/ticket/13139

Custom type not showing up in rule config

Trying to add a folder rule which should specialize cm:content to our custom type my:content (which inherits from cm:content).
We have configured the following in share-config-custom.xml:
<type name="cm:content">
<subtype name="my:content"/>
</type>
Our type shows up correctly in the specialize type action in the document library, but when trying to specify a rule the listbox that should contain our type remains empty. :(
What could we be missing?
You need to add to web-client-config-custom.xml in alfresco/extension
<config evaluator="string-compare" condition="Action Wizards"
replace="true">
<subtypes>
<type name="my:content" />
</subtypes>
<specialise-types>
<type name="my:content" />
</specialise-types>
</config>
And then the trick is to provide title & description for the types in the content model or via messages/properties; otherwise they will not be there.
Wrote about similar issues here: http://experiencewithalfresco.blogspot.dk/2012/08/remember-to-define-title-and.html
For adding custom messages you need to create custom-message-context.xml
<beans>
<bean id="mycompany.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco.messages.custom</value>
</list>
</property>
Then create custom.properties file and place it in /shared/classes/alfresco/message folder.
And for adding custom type to rule your config should be working only thing to make sure is config inside which you have put sub-type related config is proper.
Disclaimer: This answer is for Alfresco 6.2.2+.
Answering an old thread. For me, I tried this thread all vague answers on Alfresco Hub and nothing worked out.
I have been through this nightmare. Its frustrating and I don't know why Alfresco team relies on "Display Label" instead of "Name".
As shown in the screenshot, I was missing Display Label. As soon as I edited my custom type and provided Display Label, all worked as expected.
If I would have designed it, I would include, Name and Display Label both in the drop down in my rule window.
Hope it helps someone like me.

Creating content of custom type in Share

I am trying to have Share let the user create new documents based on a custom type I implemented (see the excellent documentation here )
I had the type implemented and defined aspects, but I can't see a clear way to configure Share in order to propose in the interface my type for a new document.
I guess it should be added to the Create content menu option that lists available types.
Thanks
You should just modify the share-config-custom.xml file in your tomcat/shared/classes/alfresco/web-extension folder (if there is no such file, search for a similar sample file and rename it). There, you should put something like this in the <config evaluator="string-compare" condition="DocumentLibrary" replace="true"> tag:
<types>
<type name="custom:myType" />
</types>
Just remember if the replace parameter is true, you will override every type visible, so maybe it's better to turn it to false.
Hope it helps
I managed to have it working by adding the following section to the share-custom-config.xml file:
<config evaluator="string-compare" condition="DocumentLibrary">
<create-content>
<content id="plain-text" mimetype="text/plain" label="Brand new content type" itemid="sc:doc"/>
</create-content>
</config>

Sharepoint MySite: Redirecting the Quick launch url

I'm personalizing the MySite page with a custom controller and custom aspx, based in the original ones inside the SPSMSITEHOST folder. What I've done is copy them in my project, create a new controller .ascx and modify the copy of person.aspx and conten.aspx. Then I indicate in the the onet.xml the new path for my pages this way:
<NavBar Name="$Resources:spscore,SubNavTab_Overview_Text;" Url="person.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Content_Text;" Url="personcontent.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Tags_Text;" Url="_layouts/CustomMySite/thoughts.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Colleagues_Text;" Url="_layouts/CustomMySite/MyContactLinks.aspx" />
<NavBar Name="$Resources:spscore,SubNavTab_Memberships_Text;" Url="_layouts/CustomMySite/MyMemberships.aspx" />
The thing is everything is working great. Every element in the quick launch menu is pointing to the right custom url and everything. Everything works great BUT the personcontent.aspx and I'm turning crazy here. The person.aspx is loaded in the same way and it works, why doesn't the personcontent.aspx? Should I change the url somewhere else?
Thanks!
I got with the problem. The url's are ok, but not the file type. It's necessary to mark them as Ghostable
<Modules>
<Module Name="Default">
<File Url="personcontent.aspx" Type="Ghostable"></File>
<File Url="blog.xsl"></File>
<File Url="tagprofile.aspx" Type="Ghostable">
<AllUsersWebPart WebPartZoneID="LeftZone" WebPartOrder="1">
...
This made the trick for me.

Embedding a spark variable to make up a string

Hi new to spark so this should be simple.
I'm converting an old webfoms page to mvc using spark.
I want to use the Base.Application to make up the src of a url
original markup
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
I've tried this in spark
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
but no joy.
How do i do this in spark?
Not sure if you're aware of this, but Spark has a DefaultResourcePathManager that will automatically locate the Site Root if you prefix the resource with a tilde, so this should work just fine, and looks neater.
<img alt="" src="~/images/screenshots/myImage.jpg" />
There's an added bonus to using this technique as well....hold on to your shorts! Without changing your view, simply by making sure you use the tilde convention, you can dynamically redirect requests for your static resources to a content delivery network (CDN) or a completely different location - even an embedded resource inside a Spark Module .dll you compile for dll drop in deployment.
For example, to hook it up to a CDN, all you'll need to do is add the following kind of thing to your Spark Settings:
<resources>
<add match="/content/images" location="http://mycdn.com/youraccount/images"/>
<add match="/content/css" location="http://mycdn.com/youraccount/css"/>
<add match="/content/js" location="http://mycdn.com/youraccount/js"/>
</resources>
...and from then on those resources will be fetched from the new location instead. This is great for scenario testing locally, and the deploying to the cloud later.
Slight tweak of the syntax has sorted it.
<img alt="" src="${Base.ApplicationPath}images/screenshots/myImage.jpg" />

Resources