Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Richard Rees 17 posts 25 karma points
    Oct 06, 2009 @ 23:54
    Richard Rees
    0

    text only site

    Hi,

    I need to create a "text-only" version of an image-heavy umbraco site I've created. The only way I can think of at he moment is to "duplicate" all my templates into text only versions and then find a way to programatically change the template at run time based on a querystring value or session of "textonly".

    The downside of this is that it means that every template I have created or will create in the future will need 2 versions - the normal version and the text-only version.

    I did think about just having a seperate css but as 95% of images on the site are rendered in <img> tags, it will take much more than css-only changes I think.

    Has anyone tried to do anything like this before? Is there a better way?

    Thanks

    Rich

  • skiltz 501 posts 701 karma points
    Oct 07, 2009 @ 01:23
    skiltz
    0

    I would be going down the css route.

    img
    {
    visibilty: hidden;
    display: none;
    }

     

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Oct 07, 2009 @ 05:08
    Peter Gregory
    0

    Hiding the image with CSS wont stop the image from downloading.  The Image will still exist in the dom.   The only fail safe way of having text only templates is to create alternate templates.

    Then all you need to do is modify you nav to run in text only mode or something and append /text-page to end of the url which would give the page rendered in a text only way on a template called text-page.

    Peter.

     

  • Jannik Nilsson 38 posts 81 karma points
    Oct 07, 2009 @ 08:58
    Jannik Nilsson
    0

    Why not just add a query, fx. www.site.com/?light=true, then in your templates test for that and don't render your images

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 07, 2009 @ 09:33
    Lee Kelleher
    0

    Hello there Mr Rees!

    Here's another "out there" alternative solution.  Create a new base page class that inherits from "umbraco.UmbracoDefault" and override the Render() method.  In there you can use some RegEx to remove all unwanted HTML from the HtmlTextWriter object, like <img> tags, etc.

    Personally, I'd go with the alternative templates approach, it will give you greater flexibility in the end.

     

    Do remember that you can take advantage of the 404handler "SearchForTemplate" ... so rather than using:

    http://example.com/page.aspx?altTemplate=text

    You can use:

    http://example.com/page/text.aspx

     

    Cheers, Lee.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 07, 2009 @ 09:38
    Lee Kelleher
    0

    Just thought of another solution. [I wish we could edit our forum posts]

    You could add a UrlRewriting rule to rewrite pages with /text/ prefixed in the URL:

    <add name="TextOnly" virtualUrl="^~/text/(*).aspx" destinationUrl="~/$1.aspx?altTemplate=text" rewriteUrlParameter="ExcludeFromClientQueryString" ignoreCase="true" />

    The only problem is how to persist the Text Only links through the navigation, which you could do via an XSLT extension?

  • Richard Rees 17 posts 25 karma points
    Oct 07, 2009 @ 14:41
    Richard Rees
    0

    Thanks everyone for the replies - Hello Lee - just like old times!

    I think its definitely going to have to be the alternative template approach - I think removing images on existing templates will screw the layout.

    Regarding persisting the "text only" variable through the site - I'm currently doing that by using session variables in a user control in my master page. So I guess I just need to set a new "text only" variable (if the user clicks on the text only site link) and then interrogate this variable on every page and then somehow set the template programmatically? Is this possible I wonder?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 08, 2009 @ 02:14
    Lee Kelleher
    0

    Richard, take a look at the following forum topics about using a HttpModule to handle dynamic MasterPages:

    http://our.umbraco.org/forum/developers/api-questions/3687-dynamic-master-page

    http://our.umbraco.org/forum/developers/api-questions/3732-IHttpModule-and-Umbraco

  • Mark Radford 7 posts 30 karma points
    Jul 14, 2011 @ 20:05
    Mark Radford
    0

    This post helped me a lot today.  Specifically, Lee Kelleher's suggestion about using a RegEx to remove markup when not wanted.

    To give you a bit of background, I needed to produce HTML and plain-text output for a page (to be pulled into Campaign Monitor to become email content).  To do this, I used the ?AltTemplate querystring parameter to switch to a different template and modified the render method in my new masterpage to strip out the HTML tags.

    It ended up working really well.  For anyone who's looking for some info on how to override the Render method, this helped me:

    http://www.west-wind.com/weblog/posts/2004/Jun/08/Capturing-Output-from-ASPNet-Pages

    Cheers everyone!

Please Sign in or register to post replies

Write your reply to:

Draft