Automatically create links to content in a folder - umbraco

I have 2-3 HTML files created per week that will be uploaded via FTP to a folder on the web server. The files are just plain HTML having results from my local Bridge Club.
Before I go ahead and spending time creating a "fancy" solution in .Net for this I better ask if there is any built in support for this in Umbraco.
Basically I want to have a main menu item called Results, and that page should have a secondary menu with links to each .HTML file in a specific folder
Any ideas?
Cheers,
Stefan

First, make sure you put the path that the html files are being uploaded to within the umbracoReservedPaths app setting in the web.config.
Next I would create an XSLT extension (or custom function that returns an XPathNodeIterator containing each HTML file name. The method will need to build an XmlDocument that looks something like:
<files>
<file>/htmlfiles/file1.html</file>
<file>/htmlfiles/file2.html</file>
<file>/htmlfiles/file3.html</file>
</files>
Then call CreateNavigator() on the XmlDocument and return that from the XSLT extension method. Use Directory.GetFiles to get the list of HTML file names and convert them to a web ready URL like /htmlfiles/file1.html.
Then display it all with a simple XSLT macro that iterates the result of your XSLT extension in a for-each. That would look something like:
<xsl:for-each select="customExtensions:GetFiles()//file">
<a>
<xsl:attribute name="href">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:text>File #</xsl:text>
<xsl:value-of select="position()" />
</a>
</xsl:for-each>
This would generate a list like
File #1
File #2
File #3
all linking to their respective value in the xml.
A good example of an extension method is here

Related

Dhtmlxgrid 4.0 doesn't load data from the ASP.Net MVC view

In my ASP.Net MVC web application I used to have dhtmlxgrid plugin v 3.5 and now updated to v4.0.
Before it was easy to generate dynamic values for the grid in separate .cshtml view and only pass the url of the method inlo loadXML like this:
myGrid.loadXML('#Url.Action("XmlValues")');
Now in the version 4.0 they replaced loadXML() with load(), which still should be able to do the same thing. But instead of parsing the data into the grid it shows an alert with an xml code generated inside the view and the table body is empty. It can't even load simple xml if it was passes through the view:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row id="1">
<cell>1</cell>
<cell>2</cell>
</row>
</rows>
But if I copy that into an external xml file and pass path to the file into the method it works correctly.
myGrid.load("/xml.xml");
What is the problem with new load() method and how to make it work with dynamic data in ASP.Net MVC as I used to?
please make sure there are no extra chars in the generated xml. For example, a space (" ") before the xml header.

Adding a ApplicationBarIconButton from Application.Resources in XAML

I have a ApplicationBarIconButton which I use repeatedly on multiple pages.
I want to be able to define the Click action in my Application C# file.
I have
<Application.Resources>
<shell:ApplicationBarIconButton
x:Key="AddLocationAppBarIconBut"
IconUri="/icons/appbar.add.rest.png"
Text="location"
Click="Add_Location_Event" />
in my App.xaml file and I want to load it into another page I have under
<phone:PhoneApplicationPage.ApplicationBar>
How do I go about this exactly?
Can I bind a click event to an event in my Application cs file?
Unfortunately, you can't!
In full WPF framework, you'd be able to do something like this:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar>
<shell:ApplicationBar.Buttons>
<StaticResource ResourceKey="AddLocationAppBarIconBut" />
</shell:ApplicationBar.Buttons>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
The trick here is in the usage of StaticResource, but Silverlight doesn't have a backing class representation like that; you can only use the Markup Extension as {StaticResource AddLocationAppBarIconBut}, but this won't help you here!
What you can is define the full ApplicationBar object as a resource and then just call it on the page like this:
<phone:PhoneApplicationPage ApplicationBar="{StaticResource ApplicationBarResource}">
<!-- remaining code -->
<phone:PhoneApplicationPage />

Use of xi:include in Orbeon

I created a form using Orbeon form builder, and i included in its form instance the content of an xml file using :
<xi:include href="oxf:/path/file.xml" xxi:omit-xml-base="true" />
When i save the form in form builder and edit it, i get a new form, and when i publish it and run it in form runner i get a blank page.
Can you tell me please what's wrong with the xi:include ?
If you want to include the whole content of an external file as the instance, use:
<xforms:instance id="main-model-instance" src="oxf:/path/file.xml"/>
Here we have the model instance xml in external file at /path/file.xml and we are using this file into our form and have named the model instance as id="main-model-instance"
If you need to add part of the instance from external file, then insert that piece dynamically during xforms-model-construct-done event, e.g.:
<xforms:action ev:event="xforms-model-construct-done">
<!-- Extracts the element some-section from file.xml and uses it as the
root element of the fr-form-instance -->
<xforms:insert context="instance('fr-form-instance')"
origin="doc('oxf:/path/file.xml')/root-element/some-section" />
</xforms:action>

ucommerce: how to change category template

Using uCommerce 2, umbraco 4.7.
I have a category side nav showing the categories using:
<a>
<xsl:attribute name="href">
<xsl:value-of select="CommerceLibrary:GetNiceUrlForCategory($catalogueName, #id)"/>
</xsl:attribute>
<xsl:value-of select="#displayName"/>
</a>
First of all, when hovering over the links it still shows an old catalogue name, even though I've renamed the catalogue and also hardcoded the catalogue name into:
<xsl:variable name="catalogueName" select="'MyCatalogue'"/>
When I click on the link generated by GetNiceUrlForCategory I get the standard template that comes with uCommerce started site. I've tried deleting the whole started site, but I just can't get it to link to a template I did for the category.
I still don't quite understand how ucommerce knows which template to use for a category link.
Soren? :)
Cheers,
Matt
Found answer: Change in UrlRewriting.config ... simpelz

How to localize javascript files in a Struts 2 app

I wrote an Struts 2 application and want to localize it. Now I am using javascript and I would like to put the scripts out of my HTML template to an own javascript file.
When I do it, my s:text tags are not rendered (of course).
Question is how can I localize my javascript files with Struts 2 in a clean way? I would like to avoid to use another technique than the properties files i currently use.
Thanks,
Christian
If you want to stick with your resource bundles back at server, one way possible would be to save your javascript files as .jsp file and serve them with an action so this way your struts tags in your javascript files will get a chance to retrieve the data from server and return the file upon request.
Personally I prefer to keep client messages in javascript files and server messages in resource bundles. This way you can save a .jsp processing IMHO.
You can use a hidden field in your JSP and pass its id to the external JavaScript file and get its value like follows.
In your JSP,
<s:hidden id="warning" value="%{getText('propertyKey')}"/>
(hidden field poplated with the value of the property key in the resource bundle)
Call your external JS method from the same JSP,
<s:a href="%{deleteSelected}">
<img src="<s:url value='/images/delete.gif'/>" border="none"
onclick="javascript:return displayWarning('warning')"/>
</s:a>
In external JavaScript file,
function displayWarning(message) {
var ret = true;
ret = confirm(document.getElementById(message).value);
return ret;
}
<script type="text/javascript">
var mytxt='<s:text name="my.text.prop" />';
alert(mytxt);
</script>
This is also possible, but you cant have them inside a function.You should assign relevant properties to global JS variable at the time of page load. Almost same concept slimier to use hidden variables.

Resources