Announcement

Collapse
No announcement yet.

How to get current page url with PHP?

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

    How to get current page url with PHP?

    Hi everyone,
    I've tried $_SERVER['PHP_SELF'] to get page url, but there is something wrong with it.
    Have you got any other ideas how to do it???

    Thanks.

    #2
    Welcome Hubert.

    It may be easier if you tell us what you want to achieve.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      I've got few different pages which run the same php script.
      to work properly the script needs to get the name of page that is currently running it.
      usually that info was stored in $_SERVER['PHP_SELF'], but array $_SERVER stores some strange data. I don't know if it's a fault of actinic or something else.

      Comment


        #4
        I'm assuming we're talking about PHP pages running on your web-server. Not the PHP that Actinic runs internally on your desktop system to help it build the pages.

        Actinic uses no server side PHP (generated pages are usually .html) so will not be changing the way your server works in any way. One for your server support people, I think.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          thanks for info
          helped a lot

          Comment


            #6
            If your PHP is coded inside Actinic you may have enough using the existing Actinic variables to insert the URL as you know the site address and a page on the server is a section ... combine the 2 to provide the URL.... or is it not that simple?


            Bikster
            SellerDeck Designs and Responsive Themes

            Comment


              #7
              maybe it's easy, but I use actinic for the first time and it looks quite strange to me.

              tried to put some info about page title to php script by:

              Code:
              		<actinic:block if="%3cactinic%3avariable%20name%3d%22PageTitle22%20%2f%3e">
              		<actinic:block php="true" >
              		
              			
              			$adr = <actinic:variable name="PageTitle" />;
              			echo $adr;
              			
              		</actinic:block>	
              		</actinic:block>
              but I get errors...
              Can you explain to me what's wrong?

              Comment


                #8
                Can you explain to me what's wrong?
                The page title variable needs to be enclosed by quotes. Also the variable should have the selectable property set to false. I.e. you need something like

                Code:
                <actinic:block php="true" >
                	$adr = "<actinic:variable name="PageTitle" selectable="false" />";
                	echo $adr;
                </actinic:block>
                I hope this helps.
                Zoltan
                Actinic Software
                www.actinic.co.uk

                Comment


                  #9
                  Great thanks zmagyar!
                  All works just fine,
                  you're the man

                  Comment


                    #10
                    I'd use (if you're getting a string)

                    $adr = '<actinic:variable name="PageTitle" encoding="perl" selectable="false" />';

                    Just in case your variable contains a single quote (PageTitle probably won't but other variables may well).

                    Here's a copy from a post I made yesterday about this:

                    If you're converting Actinic variables into PHP strings then you should do it via single quotes. And you don't need quotes around numbers.

                    The encoding="perl" tell Actinic that you want to use this variable in a quoted string. I'll show you why. Let's imagine we don't use encoding="perl". If your variable contains ABCD we're going to generate

                    $adr = 'ABCD';

                    Which is just what we wanted.

                    Now if your variable contained Plenty O'Tool we'd have

                    $adr = 'Plenty O'Tool';

                    And, oh-oh, that's a PHP syntax error as PHP thinks that the middle quote ends the string and tries to interpret Tool' as code.

                    Now with encoding="perl" what Actinic does with Plenty O'Tool is

                    $adr = 'Plenty O\'Tool';

                    And PHP now knows that the middle quote is part of the string.

                    The selectable="false" tells Actinic not to embed any additional code around the variable. It does this mainly in the Design view (so the objects can be clicked upon) and this stuff will break our PHP. When the page is Uploaded or Previewed normally, all that guff disappears.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      What Norman says is correct.

                      Just one hint to add. You can use the selectable="false" on the block level as well. If there are lots of Actinic variables referenced inside the PHP code it's more simple to set this on the block rather than the individual variables.
                      Unfortunately it's not available on the UI but you can add it to the code editor in advanced mode.
                      Zoltan
                      Actinic Software
                      www.actinic.co.uk

                      Comment


                        #12
                        You can use the selectable="false" on the block level as well
                        Now that I didn't know. Very useful info. Thanks for pointing it out.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment

                        Working...
                        X