had a client ask me to develop something for them this morning and thought i would share....
client wanted a little checkbox on a page confirming they agree, then activate a button to take you to an off site appliction... no data storage or anything going on on the umbraco side... i just needed a deactivated button, a checkbox to activate it and a macro to really let the client take care of this because they were not entirely clear on the forwaring url, etc.
A useful post, but not sure it's the right place for it?
Just a thought, maybe we should create a section of the Wiki for "code snippets" where things like this are collected, as I see the forum is really for questions and answers, but code like this would maybe be easier to find if it had an area on the wiki.
I am guessing you don't have a blog that you could have posted it onto? ( but even if you did.. getting an area on the our. site for code would be great :) )
yeah, i debated long and hard where to put it... it wasn;t really extending umbraco... it doesn't really fit xslt [but kinda] so i totally dig your idea for adding an area... who do we ask? NH? Dirk? - oh, but wait...you too look to be an admin, my friend! Make it so! ;)
okay, i created a new category in the wiki under reference and placed the snippet above in there. Feel free to delete this one or add snipets to the wiki :)
sharing a client request and solution
had a client ask me to develop something for them this morning and thought i would share....
client wanted a little checkbox on a page confirming they agree, then activate a button to take you to an off site appliction... no data storage or anything going on on the umbraco side... i just needed a deactivated button, a checkbox to activate it and a macro to really let the client take care of this because they were not entirely clear on the forwaring url, etc.
so, here is what i did....
first, made sure i had jquery on the page...
then, wrote this little function...
<script type="text/javascript">
/* <![CDATA[ */
function toggleStatus() {
if ($('#toggleElement').is(':checked')) {
$('#elementsToOperateOn :input').removeAttr('disabled');
$('#elementsToOperateOn :input').addClass('pretty-button');
} else {
$('#elementsToOperateOn :input').attr('disabled', true);
$('#elementsToOperateOn :input').removeClass('pretty-button');
}
}
/* ]]> */
</script>
made sure i set the form/button to inactive on my document.ready code...
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){
$('#elementsToOperateOn :input').attr('disabled', true);
});
/* ]]> */
</script>
then, i created a simple xslt macro -- allowed it to be inserted into the wysiwyg editor and viola! here is my xslt...
<xsl:template match="/">
<xsl:variable name="confirmText" select="/macro/checkBoxText"/>
<xsl:variable name="buttonText" select="/macro/submitText"/>
<xsl:variable name="landingPage" select="/macro/landingPage"/>
<!-- start writing XSLT -->
<form action="{$landingPage}" method="post">
<p>
<input id="toggleElement" type="checkbox" name="toggle" onClick="toggleStatus()" /> <xsl:value-of select="$confirmText" disable-output-escaping="yes"/>
</p>
<div id="elementsToOperateOn">
<input type="submit" value="{$buttonText}" id="surveyButton"/>
</div>
</form>
</xsl:template>
Hope someone finds this useful for a project need up the line somewhere :)
Hi Bob,
A useful post, but not sure it's the right place for it?
Just a thought, maybe we should create a section of the Wiki for "code snippets" where things like this are collected, as I see the forum is really for questions and answers, but code like this would maybe be easier to find if it had an area on the wiki.
I am guessing you don't have a blog that you could have posted it onto? ( but even if you did.. getting an area on the our. site for code would be great :) )
Cheers,
Chris
yeah, i debated long and hard where to put it... it wasn;t really extending umbraco... it doesn't really fit xslt [but kinda] so i totally dig your idea for adding an area... who do we ask? NH? Dirk? - oh, but wait...you too look to be an admin, my friend! Make it so! ;)
Great snippet, but indeed fits nicer on the wiki... why not create a new area on the Reference section?
Cheers,
/Dirk
okay, i created a new category in the wiki under reference and placed the snippet above in there. Feel free to delete this one or add snipets to the wiki :)
http://our.umbraco.org/wiki/reference/code-snippets
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.