Code on Page Template vs Head Tag

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TioEsteban
    Mini Mivite

    • Jun 2009
    • 52

    #1

    Code on Page Template vs Head Tag

    What is the difference between placing code on a page template vs in the head tag content/css?

    For example, in the head tag, I have a toolkit function that creates meta descriptions if none exist with statements like:
    <mvt:if expr="g.Screen EQ 'PROD' ">
    or
    <mvt:if expr="g.Screen EQ 'CTGY'">

    Could these just as well be placed on the specific page template without the "if" code? Or is there a benefit to one way or the other?

    Thank you
    Tio Esteban
    Stowe Craft & Design Center
    www.stowecraft.com
  • Rick Wilson
    Uber Mivite











    • Aug 2007
    • 10120

    #2
    Re: Code on Page Template vs Head Tag

    The only difference is convenience. If you manage it under the tab, that can work on all of your pages.

    If you put it directly on a page template, then you must manage each page template individually.
    Thanks,

    Rick Wilson
    CEO
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment

    • TioEsteban
      Mini Mivite

      • Jun 2009
      • 52

      #3
      Re: Code on Page Template vs Head Tag

      Thank you-
      Tio Esteban
      Stowe Craft & Design Center
      www.stowecraft.com

      Comment

      • nottheusual1
        Mega Mivite


        • Jul 2008
        • 1124

        #4
        Re: Code on Page Template vs Head Tag

        If you close the head tag on every page versus in the head tag item you can do both - have large scale control and specific page code, too. Just be sure you place the closing head tag in the appropriate place on every page that calls the head tag item. Saves on lots conditionals.

        Comment

        • Siamese-Dream.Com
          Mega Mivite

          • Apr 2006
          • 3785

          #5
          Re: Code on Page Template vs Head Tag

          That sounds tempting, but there are like 80 pages or so (some of the modules I have created new pages).

          I am pretty sure I would forget to close the head tag on like 75 of them.

          If I were more organized, I owuld definitely look at doing it that way. I hate conditionals (no good reason why... I mean, I have to be OCD about SOMETHING, and it certainly isn't cleaning / doing dishes / laundry / exercise.)
          Mark Romero
          ~~~~~~~~

          Comment

          • TioEsteban
            Mini Mivite

            • Jun 2009
            • 52

            #6
            Re: Code on Page Template vs Head Tag

            Just so I'm clear on the details: What exactly does it mean to "close the head tag"?
            Tio Esteban
            Stowe Craft & Design Center
            www.stowecraft.com

            Comment

            • nottheusual1
              Mega Mivite


              • Jul 2008
              • 1124

              #7
              Re: Code on Page Template vs Head Tag

              All basic HTML tags open and close. In the case of the head tag, you'd leave this part in the MIVA HTML Profile item contents:

              Code:
              <head>
              And then put this at the top of every page right below the call for the item, like this:

              Code:
              <mvt:item name="html_profile" />
              </head>
              which closes the opening HEAD tag and lets you put things in the head section unique to specific pages.

              Comment

              • Bruce - PhosphorMedia
                Developer Partner











                • Mar 2006
                • 11256

                #8
                Re: Code on Page Template vs Head Tag

                FYI: This is all "stylistic" or "habit", but a lot of coders would refrain from putting code explicitly in a template when it could be rendered via a conditional. (That's why they invented conditionals :) ).

                This would be fine, perhaps, if you where writing out a title tag that was unique for every page, as you'd have to go "someplace" to change each one, but...you wouldn't want to declare your jQuery reference within the page template.
                Bruce Golub
                Phosphor Media - "Your Success is our Business"

                Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                phosphormedia.com

                Comment

                • nottheusual1
                  Mega Mivite


                  • Jul 2008
                  • 1124

                  #9
                  Re: Code on Page Template vs Head Tag

                  "but a lot of coders would refrain from putting code explicitly in a template when it could be rendered via a conditional. (That's why they invented conditionals :) )"


                  ????

                  Comment

                  • Bruce - PhosphorMedia
                    Developer Partner











                    • Mar 2006
                    • 11256

                    #10
                    Re: Code on Page Template vs Head Tag

                    Re-enforcing the idea that conditionals are almost always a better approach (from a maintenance perspective) than spreading stuff out through multiple templates.

                    I'd personally opt to use conditionals. That way, I only have to look in one place to see how out put is generated.
                    Last edited by Bruce - PhosphorMedia; 06-02-14, 09:43 AM.
                    Bruce Golub
                    Phosphor Media - "Your Success is our Business"

                    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                    phosphormedia.com

                    Comment

                    • nottheusual1
                      Mega Mivite


                      • Jul 2008
                      • 1124

                      #11
                      Re: Code on Page Template vs Head Tag

                      Sorry, but I don't see the utility of every page render grinding through conditionals when I want a cookie written on the basket page. I think that's where the question was, similarly.

                      Comment

                      • Bruce - PhosphorMedia
                        Developer Partner











                        • Mar 2006
                        • 11256

                        #12
                        Re: Code on Page Template vs Head Tag

                        Not much 'grinding' going on with 'g.screen EQ 'BASK'.

                        The benefit is, when I look at the "head" template (for example) I can easily see that the basket screen has a special case applied to it.
                        Bruce Golub
                        Phosphor Media - "Your Success is our Business"

                        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                        phosphormedia.com

                        Comment

                        Working...
                        X