Plone 4 Zope Display Contents of specific folder TALES - plone

Problem
I have a customer that wishes to display the entire contents of a certain folder (containing images) on their search page, should the search return 0 results. The folder is located at mysite.com/images
Setup:
As a test environment I have setup a seperate site with the following structure:
ROOT
|-Folder1 <-- current directory I am viewing
| |-images
|-Other folders
I modified the folder_summar_view template, to include the following code (I decided to modify a view to see if I could hack that to pieces to make it do what I want):
<div tal:define="image context/images/getFolderContents">
<div tal:content="i" tal:repeat="i image" />
</div>
What I see:
<Products.ZCatalog.Catalog.mybrains object at 0x9d2ddb8>
Things I've tried and further explanations
I was under the assumption that when the context/images/getFolderContents returns a brain for the 'objects' in my images folder, I could then iterate through each 'object' using my tal:repeat statement below it. Then display them on my page.
If I just use the following code:
<div tal:content="context/images/getFolderContents" />
My output is very similar to the above 'What I see' section:
<Products.ZCatalog.Catalog.mybrains object at [...]>
where [...] is another number
I've been doing some research and reading the Plone Theming book, but my code is similar to their tal:repeat examples on page 169, it seems the only difference is they are not using this on a brain (as far as I can tell).
I tried this, although it produced the same results (not sure why I tought it wouldn't):
<div tal:define="image python:context.images.getFolderContents()">
<div tal:content="i" tal:repeat="i image" />
</div>
I don't seem to be able to 'get inside' the returned brain. Everything I've looked for online doesn't quite help that much, I've also trawled through the atct_album_view and folder_listings templates to know avail. - I think I'm overlooking or missing something.
The first link I stumbled across was this, however I have moved on since that as although similar, it's not quite what I was trying to do.
The Plone guys on their chat room were kind enough to give me the context/images/getFolderContents statement, I tried to press on without asking for help again but it seems I've hit a wall.
More stuff I've tried
Using this link as inspiration I decided to try the following:
<div tal:define="image context/images/getFolderContents">
<div tal:content="image/getURL" />
</div>
But that throws an error when I try to view the template. The error reads along the lines of the 'getFolderContents brain does not have the attribute getURL' - Although image/Title displays the name of the folder, but that's not really what I need.
I also found this link however because I am making use of the default search, I don't really want to have to edit python scripts as I fear it may adversely effect the normal Plone site search. Also in this link they seem to be making use of more Python scripts. - To expand on this point, I'm not sure on how these scripts 'link' with page templates (how they know to 'talk' to one another).
Conclusion
In conclusion I need to display all of the images contained within a folder named "images" located at the root of my site, I am unable to access the contents of a returned brain using getFolderContents. And other than displaying the title of the "images" folder or the brain identifcation (<Products.ZCatalog.Catalog.mybrains object at 0x9d2ddb8>) , I have had no luck. Any help or ideas welcomed!

As getFoldercontents returns a list of brains i cant see how your code can work.
Just repeat over it with something like that :
<tal:block tal:repeat="image context/images/getFolderContents">
<a tal:attributes="href image/getURL" tal:content="image/Title"/>
</tal:block>

Related

Tag links not working in beautifulhugo blog

I'm trying to build a blog using a combination of RStudio/blogdown and using the beautifulhugo theme from halogenica/beautifulhugo. When I create a new website using the stock template from github and the RStudio GUI/serve_site() everything works fine (as far as I can see) except the tags on the main page don't work (when I click them they say my computer isn't connected to the internet). I'd like to find out how to fix this... or learn how to work this properly, before I start changing stuff in the stock setup/building a blog.
This tag issue is repeated on each posts' page and on the dedicated "Tags" page when I click "View all" under each tag.
Am a complete noob here - am likely doing something wrong. I managed to "fix" the "View all" issue using https://github.com/halogenica/beautifulhugo/issues/142, but I'm guessing there is a more general issue with what I'm doing: I need to fix it once centrally, or perhaps perform a similar modification to other parts of the code?
Never mind - I found out what was wrong. The above fix corrects one of the issues in terms.html (layouts/_default). In the same folder there was an "error" (which I'll no doubt find out is correct at some point in the future) where there was an extra "/" being put into the tags link. I had to change
{{ . }}
to
{{ . }}
in both list/single.html in the same folder as above. Note these only differ in the slash before tags.

Load resources in gadgets in Jira

I've made an Add-on which is a custom field.
The style of the text in the field changes depending on the properties of an issue.
I check which style should the text have in the .java file and I pass the html class in a variable called $indicator to the velocity template:
#if( ${value} )
<span class="$indicator">${value}</span>
#end
It works perfect everywhere but in gadgets. When I add this field to a table showing issues in a dashboard, the html code is correct, but it doesn't find the css resource. This is because gadgets are inside an iframe.
How can I make the iframe have a reference to the stylesheet?
You did not say exactly which gadget you were using, but try adding the following context within your <web-resource> module:
<context>jira.webresources:issue-table</context>
The above should work for at least Assigned to Me, Filter Results, In Progress, Voted, and Watched in JIRA 6.1+.
If that does not work, you might also try:
<context>com.atlassian.jira.gadgets:common-lite</context>
If that general context doesn't work, you can look for which exact contexts are #requireContext'ed by the specific gadget you are trying to use, and then make sure that your web-resource is listed in that context. You can figure this out by looking at the gadget's XML and then searching for the #requireContext. (You can find the gadget XMLs inside $JIRA_DATA/plugins/.osgi-plugins/transformed-plugins/jira-gadgets-plugin-*.jar)
Starting with JIRA 7 the Answer of Scott Dudley is no longer working. #requireContext was replaced with a #requireResource within the Atlassian sources of this gadget.
As it affects our plugin, I created a Improvement Request to make that possible again

Plone 4 is rewriting my HTML, can this be disabled?

We have a Plone 4.1 site. When I edit the HTML source of a document to use a path from the root directory (/codes in our case) and save it, Plone will translate the HTML (in our case it becomes ../codes). Is there a way to disable this, at least for this page? We cannot point to it using the file system because this is a virtual directory used to retrieve and display data from MySQL tables.
Here is some code:
<div class="agency_cd">The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available. <strong>[ <a class="internal-link" href="../codes/agency_cd_query?fmt=rdb">Tab-separated -- saved to file</a> || <a class="internal-link" href="../codes/agency_cd_query?fmt=html">HTML</a> ] </strong></div>
I change it to:
<div class="agency_cd">The agency that is reporting the data. Agency codes are fixed values assigned by the National Water Information System (NWIS). A list of agency codes is available. <strong>[ <a class="internal-link" href="/codes/agency_cd_query?fmt=rdb">Tab-separated -- saved to file</a> || <a class="internal-link" href="/codes/agency_cd_query?fmt=html">HTML</a> ] </strong></div>
I then save it, but Plone reverts it to the way it was before.
Do file a bug report on this. The component at fault is an output filter that is automatically translating absolute links to the same host to relative ones. That filter probably poses problems for various "inside-out" rewriting schemes.
Meanwhile, I'll bet you can fix this with some custom rewrite rules. Put in a rewrite rule that looks for /codes-and-parameters/codes/(.+) URLs and rewrites them to /codes/$1. That way you won't need to break anything in Plone to work around the problem.
Disable TinyMCE URL Conversions was useful although I could not say it definitely solved my problem. I found that selecting the option on the Plone edit screen to not use the visual editor and edit the HTML seemed to offer a workaround. The link though is not obvious.

FeedWordPress not parsing images properly

I recently installed WordPress and have been slowly learning how to use it. I've tried to solve this one problem for about an hour now, and I can't seem to find the problem.
No matter what feed I add to FeedWordPress, it just doesn't parse the images correctly. (But it does, see here): http://ttgdark.com/
It's like it's completely remove the path to the image in the src tag.
Does anyone know what's going on?
go to you source code find this:
<img src="http://ttgdark.com/wp-content/themes/Webly/timthumb.php?
http://feeds.feedburner.com/~r/ThatVideogameBlog/~4/PkjR8RbxWzQ
&h=200&w=200&zc=1&q=90" class="post-thumb">
and remove this line of code
http://ttgdark.com/wp-content/themes/Webly/timthumb.php?src=
it should help.

Theming Ubercart Order Panes

I am working on an Ubercart installation on a Drupal site we are producing. Everything is going smoothly, but I am now trying to setup the order page template (uc_order module), so that the frontend developers can style it up.
The page is the one you view when you go to user/[UID]/order/[ORDER-ID].
I understand how to use hooks, preprocess, theming and template functions within Drupal, but currently I cannot see a way of changing any of the markup on the "order panes" that make up the page. It goes without saying that I don't want to touch any of the module's code.
So, one of the pages is the 'Bill To' address pane:
<div class="order-pane pos-left">
<div class="order-pane-title">Bill to: </div>
Name<br>
Address<br>
Town<br>
Postcode<br>
</div>
Essentially I would like to put a class in the div, so that it looks like this:
<div class="order-pane pos-left bill-to">...</div>
<div class="order-pane pos-left ship-to">...</div>
<div class="order-pane pos-left payment">...</div>
<div class="order-pane pos-left comments">...</div>
...
I just cannot see a way of doing this.
Any help would be much appreciated.
Have you checked the latest version of UC? The release note states:
The biggest change, though, is that order invoice templates now use the theme system to allow customizations. Instead of altering the module files directly, it is now correct to override them in the theme, just like node and page templates.
...and if I am not mistaken (a few months have passed by since I worked with UC), the invoice IS the page displayed by the URL you provided.
If my memory failed me (I haven't a UC installation handy to verify myself), a possible workaround (admittedly far from elegant, but still allowing you not to change the module's code) would be to alter the HTML with jQuery once the page has been loaded.
A more hack-ish workaround would be to maintain your own page callback for that URL, and just alter the menu definition in the UC code [yes, it's still hacking the code, but in this case you just need to modify one line in the UC code, and can maintain your code in a separate module].
HTH,
Mac.
You can create youre own panes or a single pane for everything, look up hook_pane, or you can insert the classes using jquery.

Resources