How to display random pictures

... in the header, for example like on http://chregu.freeflux.net/

Open master.xsl and search for <div id="banner">, and replace it with

<div id ="banner" >
 <xsl:variable name="rand">
   <xsl:value-of select="php:functionString('bx_helpers_int::getRand', '1','14')"/>
 </xsl:variable>
 <xsl:attribute name="style">background-image: url('/files/header_small/pic<xsl:value-of select="$rand"/>.jpg')</xsl:attribute>

In the example above, you'd now have to upload 14 different pictures into /files/header_small/ with the names pic1.jpg, pic2.jpg, pic3.jpg, etc. Adjust the code accordingly :)

Now, a different (randomly selected) background image should appear for the banner-div. You can of course use the same technique for any other element.

Comments (3)  Permalink

cocomment enabling your blog with Flux CMS 1.4 and later

As mentioned in another post, Flux CMS can be made cocomment enabled (or if you install it, it already is). But our comment form has slightly changed with the 1.4 release of Flux CMS, so you maybe have to adjust the cocomment code in your blog.xsl. The correct code is now:

<xsl:if test="$singlePost = 'true'">
<xsl:variable name="entry" select="/bx/plugin[@name = 'blog']/xhtml:html/xhtml:body/xhtml:div"/>
<xsl:if test="$entry/@blog:post_comment_allowed='1'">

/* cocomment elements*/
var blogTool               = "Flux CMS";
var blogURL                = "<xsl:value-of select="$blogroot"/>";
var blogTitle              = "<xsl:value-of select="$dctitle"/>";
var postURL                = "<xsl:value-of select="$blogroot"/>archive/<xsl:value-of select="$entry/@blog:post_uri"/>.html";
var postTitle  = "<xsl:value-of select="$entry/xhtml:h2/text()"/>";
var commentAuthorFieldName = "name";
var commentAuthorLoggedIn  = false;

var commentFormID          = "bx_foo";
var commentTextFieldName   = "comments";
var commentButtonName      = "bx[plugins][blog][_all]";

</xsl:if>
</xsl:if>

Hope that helps

Related Entries:
cocomment enabled
Tagcloud Plugin
Make private post got more useful
rel="bookmark" added to permalinks
Problems with FCKEditor and Firefox 1.0
Comments (0)  Permalink

How to enable standard .htaccess password protection for Flux CMS

If you want to protect your whole Flux CMS installation with a standard mod_auth .htaccess setup, then you have to set allowHTTPAuthentication in config.xml to false:

 <allowHTTPAuthentication>false</allowHTTPAuthentication>

Now, mod_auth and Flux CMS don't disturb each other anymore (the only thing not possible anymore with this is to check for blog posts marked private via RSS and http auth, but there's another way to do this now, which we'll cover later )

Comments (0)  Permalink

Prevent spam via contact form

Increasingly, spambots are taking any form they can get, so it's not surprise there's more and more of this useless shite coming through the contact form...

Now, there's an easy way to prevent this, I just committed a new patforms element called Bottest. It works with the old, but still effective technique of having a via-css-hidden formfield. If it's filled out, it's most certainly a bot :)

How to add it to your form:

- Upgrade the CMS to the trunk or the 1_4 branch. Or just put this file inc/patForms/Element/Bottest.php into the right folder.
- Then add the following line to your contact form table in /contact/index.en.xhtml

<tr class="formurl"><td forms:fieldErrorID="email" nowrap="nowrap"><i18n:text>Bot-Test (leave blank)</i18n:text>:</td><td class="formgenerell"><patForms:Bottest label="i18n(E-mail)" name="homepage" required="no" description="" /></td></tr>

And make sure the the css-class "formurl" has a display: none in your CSS.

Hope that helps..

Comments (3)  Permalink

Using https with Flux CMS

Using https with Flux CMS is not a problem by design, but we had the following harcdoded by default in config.xml:

<constants>
        <constant name="BX_WEBROOT">http://{$_SERVER['HTTP_HOST']}/</constant>
</constants>

This always switches back to http:// and therefore make the https:// mode unusable.

If you only want to use https, the solution is easy, just change http:// to https:// above. But if you're in a mixed environment, you were lost. Until now. Apply this patch to your installation and change the above config line to

<constants>
        <constant name="BX_WEBROOT">http(s)://{$_SERVER['HTTP_HOST']}/</constant>
</constants>

and it should work in both, http and https. Of course, you can also just update your installation to the latest trunk or 1_4 branch (but you still have to change the config.xml, and the http-only is still the default, if you install from scratch)

Update: There was one check in master.xsl for http://, therefore you have to patch that to. See this patch for the details.

Comments (1)  Permalink

Reuse static content with xinclude

In an effort to share more knowledge about how to develop webpages with Flux CMS, we start a this new category called "Snippets", which will contain little code-snippets, tips and tricks about how to get the most of Flux CMS. This is mainly stuff, we use in our daily coding life :) So let's start:

Sometimes you have to reuse the same static content in different places on a webpage. The xhtml plugin, which is mainly used for static content, supports the xinclude standard for including snippets of other XML documents (better said, the libxml2 library supports the xinclude standard, the xhtml plugin just calls this).

Let's say you want to include the <div id="content"> element from another xhtml document, then you just have to add the following line to your xhtml document:

<div id="content">
        <xi:include
href="../anothercollection/index.de.xhtml#xmlns(xhtml=http://www.w3.org/1999/xhtml)xpointer(/xhtml:html/xhtml:body/xhtml:div[@id='content']/node())"
parse="xml"/>
</div>

You should not forget to define the xinclude namespace, somewhere in that document:

xmlns:xi="http://www.w3.org/2001/XInclude"

That's it. You now only have to edit the content at one place (in anothercollection/index.de.xhtml).

The xpath in xpointer() can be anything you like, and be aware, that the href attribute has to be relative. You also can include arbitrary xml files this way, they don't have to be xhtml resources.

There are some ideas to make that easier for the enduser, so he/she doesn't have to remember that whole xi:include string, but these are just ideas and no ETA on that.

Comments (0)  Permalink
1-6/6