Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

PHP in cPanel skin

Discussion in 'User Experience' started by jprl12, Jul 6, 2007.

  1. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    151
    Hi!

    I need to use some PHP code in my cPanel skin. So, I will begin a new skin with only PHP files. This work fine.

    But, how can I use cPanel variable in my code? In the normal HTML skin, this line : <cpanel print="$CPDATA{'DNS'}"> will show the domain of the account. I need to use these variables for do some search in MySQL database.

    For example, I tried this :
    <?php

    echo $CPDATA{'DNS'};

    ?>

    OR

    <?php

    echo $CPDATA['DNS'];

    ?>

    But, no result ... Can you help me?

    Regards,
    Jean-Philippe Rivard Lauzier
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    316
    Location:
    All over Europe
    CPanel will first parse its own tags, then will reparse the file, parsing any php tags. So, it should look like:

    <?php
    echo "<cpanel print="$CPDATA{'DNS'}">";
    ?>


    First parsing will result to:

    <?php
    echo "mydomain.com";
    ?>

    which will then lead to the desired result.

    kosmo
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    151
    Thanks!! This code work correctly!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    316
    Location:
    All over Europe
    Glad to have been of some help (which has been rare lately :D)

    kosmo
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    151
    I have a new question about PHP and a cPanel skin ...

    This line, it's for list the MX entry : <?cp Email::listmxs(% ,mx) ?>

    We can use this line : <?cp Email::listmxs(% ,mx) domain=mydomain.com ?> for list MX entry for a specific domain.

    This code, will put the cPanel tag information in a PHP variable :
    HTML:
    <?php
    $myVar = '<?cp Email::listmxs(% ,mx) domain=mydomain.com ?>';
    echo $myVar;
    ?>
    Now, my question, how I can write PHP in the cPanel tag? By example, for have a dynamic selection for the domain :
    HTML:
    <?php
    $myDomain = 'mydomain.com';
    $myVar = '<?cp Email::listmxs(% ,mx) domain='.$myDomain.' ?>';
    echo $myVar;
    ?>
    For sure, this code doesn't work ... Somebody have a solution for that?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    151
    Nobody could help me?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. activa

    activa Well-Known Member

    Joined:
    May 23, 2006
    Messages:
    209
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Morocco
    cPanel Access Level:
    Root Administrator
    myDomain has been declared in php tag and you have included it in cpanel tag , i think the rl code must be something lik this :

    Code:
    <?php
    $myDomain = 'mydomain.com';
    $myVar = '<?cp Email::listmxs(% ,mx) domain= ?>'$myDomain'<?cp ?>';
    echo $myVar;
    ?>
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice