Announcement

Collapse
No announcement yet.

block if inside tag

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    block if inside tag

    can a block expression go inside an <li here >
    and can a function response be inside expression or does the whole function have to be in there.

    this is the function to get page url:

    PHP Code:
    <%
    function 
    curPageURL()
     
    dim sprotocolport

     
    if Request.ServerVariables("HTTPS") = "on" then 
       s 
    "s"
     
    else 
       
    ""
     
    end if  
     
     
    protocol strleft(LCase(Request.ServerVariables("SERVER_PROTOCOL")), "/") & 

     
    if Request.ServerVariables("SERVER_PORT") = "80" then
       port 
    ""
     
    else
       
    port ":" Request.ServerVariables("SERVER_PORT")
     
    end if  

     
    curPageURL protocol "://" Request.ServerVariables("SERVER_NAME") &
                  port 
    Request.ServerVariables("SCRIPT_NAME")
    end function

    function 
    strLeft(str1,str2)
     
    strLeft Left(str1,InStr(str1,str2)-1)
    end function
    %> 
    responce

    PHP Code:
    <%
      
    response.write(curPageURL())
    %> 
    what im trying to do is get the class of the <li> tag to become <li class="current"> to show current page in tabbed menu.
    i have not begun to figure out how im going to express page url is equal to the a href inside the <li> tags yet, but i wanted to know if its poss to use blocks in this way..
    Simbo thanks you in advance again

    Location: Jersey Channel Islands

    #2
    Answer to both questions is probably "yes".

    Make a simple test and see what happens. That's how most of us find out how Actinic works.

    The PHP you've posted would only work if run on your server.

    Most of the Actinic PHP tweaks posted on this Forum and AUG refer to running PHP code on the Actinic PC when the pages are being built. Code liek you've posted above wouldn't work there.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      well chuffed this works

      HTML Code:
       <actinic:block if="%3cactinic%3avariable%20name%3d%22OuterBrochurePageID%22%20%2f%3e%20%20%20%21%3d%20%20%20%3cactinic%3avariable%20name%3d%22BrochurePageID%22%20%2f%3e" ><a class="nav" href="<actinic:variable name="BrochurePageURL" />"></actinic:block><span class=" 
      <actinic:block php="true" >
      $a=<actinic:variable name="BrochurePageID" />;
      $b=<actinic:variable name="OuterBrochurePageID" />;
      if ($a==$b)
        echo "actlarger2"; 
      else
        echo "actlarger1"; 
      </actinic:block>
      "><actinic:variable name="BrochureName" /></span></a><span class="actlarger">&nbsp;|</span>
      highlights the current broucher menu link.

      just need 2 comparison variables for section pages and im in buisiness.
      Simbo thanks you in advance again

      Location: Jersey Channel Islands

      Comment


        #4
        Watch out for spurious newlines. Best check the generated code. I think you'll have
        Code:
        <span class="
        actlarger2
        ">

        Also it's better to do
        Code:
        $a='<actinic:variable name="BrochurePageID" encoding="perl" selectable="false" />';
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          yes thats the case

          seems to work fine live though at myactinic.co.uk, but taken on board and altering.

          whats the reason for adding encoding="perl" selectable="false" to actinic variables in php scripts, is it pc to add that to every actinic variable used in php.

          i have noticed you have pointed this out to other users aswell. are there cases where my code would not have worked unless encoding="perl" selectable="false" was added.
          Simbo thanks you in advance again

          Location: Jersey Channel Islands

          Comment


            #6
            Use encoding="perl" if you intend to use Actinic variables within single quoted PHP strings (any embedded single quotes will be backslash escaped).

            Use selectable="false" to prevent Actinic from adding extra unwanted code to these variables (that lets them interact with you) when in the design mode window.

            Covered in detail in the Advanced Guide - Creating PHP Functions.

            I use these nearly all the time when using variables in Actinic's PHP.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              thanks norman

              taken on board.
              dont understand the first reason for adding encoding="perl", but dare say the penny will drop in time with more experience, php is a newly discovered tool for me and a very interesting and intuative one at that. looking forward to solving many future problems with php and blocks.
              Simbo thanks you in advance again

              Location: Jersey Channel Islands

              Comment


                #8
                no good

                my code creates a parse error, when broucher link is displayed on non broucher page, thus menu has no class applied.
                i need to find a away to add in a check to see if the variable exists.

                if
                var exits
                do
                function
                else
                echo class="myclass"
                Simbo thanks you in advance again

                Location: Jersey Channel Islands

                Comment


                  #9
                  See PHP manual for isset and / or read up on Actinic variable PageType.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    maybe a bit round the houses

                    but i think this works, checks to see if brochure page, if so tests if page is current, apply class,
                    else if not brochure page apply class.

                    HTML Code:
                    <actinic:block if="%3cactinic%3avariable%20name%3d%22OuterBrochurePageID%22%20%2f%3e%20%20%20%21%3d%20%20%20%3cactinic%3avariable%20name%3d%22BrochurePageID%22%20%2f%3e" ><a class="nav" href="<actinic:variable name="BrochurePageURL" />"></actinic:block><span class="<actinic:block if="false%20%21%3d%3d%20stristr%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e,%20%22Brochure%22%29" ><actinic:block php="true" >$a=<actinic:variable name="BrochurePageID" />;$b=<actinic:variable name="OuterBrochurePageID" />;if ($a==$b)echo "actlarger2"; else echo "actlarger1"; </actinic:block></actinic:block><actinic:block if="false%20%3d%3d%20stristr%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e,%20%22Brochure%22%29" >actlarger1</actinic:block>"><actinic:variable name="BrochureName" /></span></a><span class="actlarger">&nbsp;|</span>
                    thanks for your pointers . pagetype was the one i needed.
                    Simbo thanks you in advance again

                    Location: Jersey Channel Islands

                    Comment

                    Working...
                    X