ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Switch doesn't seem to be working for some reason

April 26, 2011 3:05pm

Subscribe [4]
  • #1 / Apr 26, 2011 3:05pm

    http://2011.barbizonmodeling.com/index.php/industry

    I’m using switch to have two classes applied to weblog entries. When I view the rendered source code through the browser I see that appropriate classes in the code. However they are not doing anything, unlike my hard coded test entries.

    I popped a red border on the offending items on the link above.

    This is the code I’m using:

    
    									
  • #2 / Apr 26, 2011 6:40pm

    Mark Bowen

    12637 posts

    This is very weird but when I use the Inspector in Safari and copy paste the class from one of the other DIVs to the one that isn’t working then it all works fine. I then pasted what I’d copied from the inspector into a text editor and it was pasting in the gallerygroupL with a space at the end of the class name, same with the other class too.

    Not too sure what is going on there as when I view the source code it doesn’t look like they’re there but upon copying and pasting they then appear. All very strange.

    Have you tried hard-coding the styles just to see what’s going on?

    Best wishes,

    Mark

  • #3 / Apr 26, 2011 6:43pm

    Mark Bowen

    12637 posts

    Aha!! On a second look I copied and pasted the HTML from Safari into a text editor and hey presto the spaces just appeared. Seems that Safari is hiding them for some reason. Perhaps because it sees them as whitespace.

    Perhaps try this instead :

    <div class='{switch="gallerygroupL|gallerygroupR"}'>

    See if changing to single quotes around the switch variable helps perhaps?

    Best wishes,

    Mark

  • #4 / Apr 26, 2011 9:46pm

    So I replaced the double quotes with single quotes with no change. I don’t see any extra spaces, and I doublechecked, so not sure about that.

    Any other clues to the issue?

  • #5 / Apr 27, 2011 6:30am

    John Henry Donovan

    12339 posts

    gofreshdesign,

    That is a weird one.

    Can you just change Mark’s code slightly so it looks like this please

    <div class="{switch='gallerygroupL|gallerygroupR'}">

    Next create a blank template and reduce it right down to the bare essentials.

    Add the relevant styles in the header as opposed to linking to the stylesheet

  • #6 / Apr 27, 2011 10:47am

    http://2011.barbizonmodeling.com/index.php/errortest

    I think I’m loosing my mind. See above the link is the test page you suggested. Same problem.

  • #7 / Apr 27, 2011 11:02am

    Mark Bowen

    12637 posts

    There’s definitely something weird going on here because when I view the page in Safari and use the Inspect Element view I can see that the class looks correct but indeed doesn’t work correctly.

    If I double click on the class name and retype it for myself then it works as can be seen in the linked movie below. I’m getting some really weird issues with viewing the source though so I can’t really say any more than that though as sometimes I am seeing spaces in the class name and sometimes not depending on what programme I am using.

    Have you tried hard-coding a div without using any ExpressionEngine tags and seeing if it still does the same thing?

    Best wishes,

    Mark

    P.S. Video link - http://cl.ly/6Hsc

  • #8 / Apr 27, 2011 11:06am

    Mark Bowen

    12637 posts

    Just pasted the HTML source code into TextWrangler and turned on Show Invisibles and got this showing - http://cl.ly/6Hv4

    There’s definitely a weird character after the class name. How exactly did you create that template code? Was it created by hand or in an editor of some sort?

    Perhaps try deleting the class names in the switch variable and retyping them by hand again?

    Best wishes,

    Mark

  • #9 / Apr 27, 2011 11:16am

    I do not understand where that extra character (the red upside down question mark) is coming from.

    I have retyped and retyped the class names in the switch variable.

    I hand coded all the HTML in a static site which before I plugged in the switch/ee stuff was working fine and rendering the classes correctly.

    Could this possibly be a host issue? I’ve never run an EE site on this host before.

  • #10 / Apr 27, 2011 11:25am

    Ok, so I’ve narrowed where the special character is coming from in the code, but I can’t figure it out still.

    However, I have gotten switch to work by putting the styles in line, visible at the same link

    http://2011.barbizonmodeling.com/index.php/errortest

  • #11 / Apr 27, 2011 11:26am

    Mark Bowen

    12637 posts

    I do not understand where that extra character (the red upside down question mark) is coming from.

    Nor me I’m afraid :-(

    That’s why I was asking if you are using an editor to create your templates perhaps? Are you doing that or typing the template code directly into the template editor in the ExpressionEngine control panel?

    Best wishes,

    Mark

  • #12 / Apr 27, 2011 11:29am

    Well, some how it’s healed it self. I don’t know how or why, but after the fourth time of retyping it by hand it seems to be working.

    Thanks for your time and help. Coding errors can be so weird and mysterious sometimes.

  • #13 / Apr 27, 2011 12:30pm

    Mark Bowen

    12637 posts

    Well, some how it’s healed it self. I don’t know how or why, but after the fourth time of retyping it by hand it seems to be working.

    Excellent news. Glad it’s working again now for you.

    Thanks for your time and help. Coding errors can be so weird and mysterious sometimes.

    Yep they definitely can be that. Sometimes weird characters can get put in by using some editors or by accidentally pressing a wrong key combination which looks like nothing has been inserted but hidden characters get in by mistake.

    Anyway, glad it’s working now for you.

    Best wishes,

    Mark

  • #14 / Apr 28, 2011 10:31am

    Sue Crocker

    26054 posts

    Thanks for the assist, Mark.

    gofreshdesign - Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases