Results 1 to 12 of 12

Thread: I'm getting mad with this....

  1. #1
    Join Date
    Jun 2003
    Posts
    47

    Angry I'm getting mad with this....

    Hi,

    after hours and hours...I can't find a solution for the following problem:

    In the admin area - I try - before I add a link, I added a new page called link_add_pre_check.php

    PHP Code:

    <?php

    include("../application.php");

    session_start();

    if(isset(
    $COOKIE_USERNAME)) 
      
    $_SESSION['indexu_session_username'] = $COOKIE_USERNAME;

    $_SESSION['indexu_session_location'] = "Administrator Area";
    $_SESSION['indexu_session_ip'] = $_SERVER["REMOTE_ADDR"];    

    function 
    pre_check_link(){
        global 
    $admin_template_path;
        
    DisplayTemplate($admin_template_path."link_add_pre_check_form.html","\$novar");
    }

    DisplayTemplate($admin_template_path."header.html","\$novar");
    pre_check_link();
    DisplayTemplate($admin_template_path."footer.html","\$novar");

    ?>
    The link_add_pre_check_form.html look like:

    PHP Code:
    <form action="link_add.php" method="post">
    <
    table cellpadding='4' cellspacing='0' border='0' width='50%'>
        <
    tr>
            <
    td class=tbl_caption colspan=2>
                
    Add New Link Step 1
            
    </td>
        </
    tr>
        <
    tr class=tbl_light2>
            <
    td>Url</td>
            <
    td width=280><input type=text size=40 name=url value='http://'></td>
        </
    tr>
        <
    tr>
            <
    td class=tbl_dark colspan=2 align=center>
                <
    input type=submit value="Get Meta Data for this Link" class=button>
                <
    input type=reset value="Reset" class=button>
            </
    td>
          </
    tr>
    </
    table>
    </
    form
    In the link_add.php I just added a few lines to the function ShowFormAddLink ()
    PHP Code:
    $meta get_meta_tags($_POST["url"]);
    $url             =     $_POST["url"];
    $description     =      $meta["description"];
    $keywords         =      $meta["keywords"];

      
    DisplayTemplate($admin_template_path."link_add_form.html""\$category,\$custom_field_form,\$add_cat1,\$add_cat2,\$url,\$description,\$keywords"); 
    In the link_add_form.html I modified:

    PHP Code:
    <tr class=tbl_light2>
            <
    td>Url</td>
            <
    td width=280><input type="text" name="url" value="<%url%>" size="50"></td>
          </
    tr>
    ...

    <
    td width=280>
            <
    textarea name=description cols=40 rows=7><%description%></textarea>
            </
    td>

    ...

    <
    td width=280>
                <
    textarea cols="40" rows="7" name="keywords"><%keywords%></textarea>
            </
    td

    And I really can't understand why JUST <%url%> is displayed but not the description and the keywords.

    Hope someone can understand what I'm trying to to... and can explain how i get the last to vars parsed from the temaplte engine. What I'm doing wrong here???

  2. #2
    Join Date
    Jun 2003
    Posts
    47

    Default

    btw: when I echo those vars
    PHP Code:
    echo $url             =     $_POST["url"];
    echo 
    $description     =      $meta["description"];
    echo 
    $keywords         =      $meta["keywords"]; 
    I get the correct data...it is there - how to get them parsed now?

  3. #3
    Join Date
    Jul 2002
    Posts
    189

    Default

    Hello heohni,

    very cool hack! I didn't know that it's that easy to grap meta data with php. I tried your script.

    Just get your variables global by

    Code:
      // vars template
      global $category, $url, $description, $keywords, $custom_field_form, $add_cat1, $add_cat2;
    That's it!

    I'll use this hack too. You should als include a db check whether the link is already in or not. I might work on that too!

    greets

    Joerg
    --------- applying hacks require a knack ---------

  4. #4
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    You should make $meta as global var.

    global $meta;

    why $_POST["url"] no need to be global. Because $_POST, $_GET, $_COOKIE, and other $_ is a 'super global' var.
    You do not need to make it global. Be careful when you're inside a function

  5. #5
    Join Date
    Jun 2003
    Posts
    47

    Default

    Cool! I'm so blind... thanks 1000 times and appologize my stupidness :-)

    tjoerg, I want to do the same, to check if links are already in the db. But for now just for the admin area, because before i run my engine I need some links there - and they must be entered by hand....and this hack (I didn't know that THIS is a hack ;-)) helps me a lot with it!

  6. #6
    Join Date
    Jun 2003
    Posts
    35

    Default

    This looks awesome but I don't really know how to go about it with the changes. Could someone post a step by step as I'm sure I'd screw it up if I tried from the info here?

    It would be much appreciated!
    IBBDB.com- Internet BulletinBoard Database

  7. #7
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    actually, all the steps are there. just do one thing at a time. if you have a problem, just post a msg here...

    and take a look at tjoerg's signature block...!
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  8. #8
    Join Date
    Jun 2003
    Posts
    35

    Default

    esm,

    I know it is clear for you but It's not everyone has the same coding background and I think you might be making some assumptions.

    I really think this should be in the mod/hack archive.

    I can follow the first post just fine but I have no idea where the

    //vars template code goes that tjoerg mentions that seems to make this work.

    BGray
    IBBDB.com- Internet BulletinBoard Database

  9. #9
    Join Date
    Aug 2001
    Location
    Indonesia
    Posts
    3,732

    Default

    Yeah ... I'd love too. Please post a complete hack.

  10. #10
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Originally posted by bgray
    esm,

    I know it is clear for you but It's not everyone has the same coding background and I think you might be making some assumptions.
    you give me way too much credit. I follow one simple rule: I make mine look like yours ( dody's in this case ). it is simply a case of "monkey see, monkey do" and I am the monkey.

    When I coined that phrase "applying a hack takes a knack" which tjoerg uses in his signature block, that is what I had in mind. I'll tell you how I did most of my hacks. Let's say I want to print something on an html page. I found a <%variable%> in that html page and I traced it back to a $variable ( a $ with the same name ) in the applicable php page. I found it usually in the DisplayTemplate function. From there I did a search "up" the page taking note of where the $variable appreared. Then I reversed the process putting my variable in the same place as $variable until I got to the html page where I put my variable inside of <% %>. Monkey, see monkey do. I literally copied what someone else had already done, I just changed the names as I went.

    Yep, I have learned a few things. An you will learn them to by doing them. I try to give detailed steps but even then the user has to ocassionally adjust what I have done because their code may be different.

    as for things being clear, well, not always. Sometimes ( many times ), I have no clue as to what I am doing. But I see what dody has done ( or maybe someone else ) and I just do what he did. I make mine look like his. A simle rule that works.

    The only programming class I have ever taken was in 1967 and we used graph paper ( well, it looked like that except the blocks were big enough to write in ) which were submitted and keypunched into cards. I wrote two "programs" - One to print "Hello World" and one to add two numbers together.

    So give it your best shot. and I'll help. ( but it may be a case of the "blind leading the blind" . Or maybe "In the land of the blind, the one-eyed man is King!" )

    Sometimes, I just rename the file on the server just in case I mess up badly.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  11. #11
    Join Date
    Jun 2003
    Posts
    35

    Default

    Originally posted by dody
    Yeah ... I'd love too. Please post a complete hack.
    Please

  12. #12
    Join Date
    Jul 2003
    Posts
    24

    Default

    Where can I find the complete Hack?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •