could you help me modify my page title?

Discussion in 'PHP' started by tigergb, May 10, 2007.

  1. #1
    could you help me modify my page title? i am working on my PHP file for several days but still can not work it out, have to return to your help.

    in my PHP files, software-description.php includes template.php, where i put my title, meta-keywords and meta-description. what I want is title, meta-keywords and meta-description change with the content of my page, for instance, let them equal to $rst["s_name"] at line 125 of software-description.php file, instead of being equal for all pages.

    i attach the two files, hoping you can help me modify them, or give me a hint how to change them? I am a newbie at this field, thanks a lot for your help in advance.
     

    Attached Files:

    tigergb, May 10, 2007 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need to load the title into a variable BEFORE the template is loaded. Usually a simple db query is suffice to get what you need.
     
    T0PS3O, May 10, 2007 IP
  3. tigergb

    tigergb Active Member

    Messages:
    500
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    thanks, is there any such an example code?
     
    tigergb, May 10, 2007 IP
  4. tigergb

    tigergb Active Member

    Messages:
    500
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    it might not work for this case as software-description.php includes template.php file.
     
    tigergb, May 10, 2007 IP
  5. tigergb

    tigergb Active Member

    Messages:
    500
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #5
    too simple to be answered?
     
    tigergb, May 13, 2007 IP
  6. Weizheng

    Weizheng Peon

    Messages:
    93
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Who did these coding? Looks real bad :D

    Here's what i think you can do -

    Do some modification to main() function in software-description.php
    1. make $rst global variable - global $rst;

    In template.php (at the top)

    1. start output buffer - ob_start()
    2. call main() function in template.php
    3. clear buffer - ob_end_clean();
    4. now all values you need are in $rst.
     
    Weizheng, May 14, 2007 IP
  7. tigergb

    tigergb Active Member

    Messages:
    500
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #7

    excellent, thanks a lot for your hint. made it.
     
    tigergb, Jul 25, 2007 IP