We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24074
    • 81 Posts
    Hi, just wanted to know how should i use if/then/else filters to change Schema.org itemscope depending on which resource is being used so i dont have to make separate template for each type.

    For example:
    Homepage:
    <html lang='en' itemscope itemtype='http://schema.org/Blog'>
    


    Blog entries under parent ~10:
    <html lang='en' itemscope itemtype='http://schema.org/BlogPosting'>
    


    General site pages like Contact, About, Services:
    <html lang='en' itemscope itemtype='http://schema.org/WebPage'>
    


    I know it can absolutely be done with simple oneliner (by Mark Hamstra smiley but seems i just can't pick up the syntax yet. Ever learning smiley

    Thanks guys! [ed. note: smashingred last edited this post 14 years, 6 months ago.]
      Radio sucks!
      • 24074
      • 81 Posts
      sorry for screwed up code, forums fault :\
      you'll get the idea of what it was.
        Radio sucks!
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        What about a TV which is either a textfield (if a techy is the editor), or a simple dropdown box with the options for non-techies. Set a default value of WebPage or @INHERIT or something similar.

        Then just use that in your template.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 3109 ☆ A M B ☆
          • 894 Posts
          You can use output modifiers, but if you're worried about performance then you might want to use the If extra.

          with output modifiers it would look something like this:

          Home Page

          [[*id:eq=`homePageID`:then=`schemaGoesHere`]]


          Blog Entries

          [[*parent:eq=`10`:then=`schemaGoesHere`]]


          Other pages

          [[*id:neq=`homePageID`:or:neq=`10`:then=`schemaGoesHere`]]


          That should take care of that with output modifiers
            Benjamin Marte
            Interactive Media Developer
            Follow Me on Twitter | Visit my site | Learn MODX
            • 27708 MODX Staff
            • 2,502 Posts
            I've actually considered using TVs for this type of metadata. Seems that most would fall into the category of no value but a blog post, product etc. would.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub