SitePoint Sponsor

User Tag List

Results 1 to 17 of 17
  1. #1
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I add <h1> to this echo table_header ( $lang['Module_Featured_Listings'] );

    This is a header title, I would like to add a H1 attribute to.

    How can I add <h1> to this,

    Code:
    echo table_header ( $lang['Module_Featured_Listings'] );
    all help greatly appreciated

  2. #2
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What does your table_header function do? Can you post the code for it?

  3. #3
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Mickyginger, good to hear from you, it just dispalys a name/title of a page box/table

    I would like that header to be H1
    Code:
    echo table_header ( $lang['Module_Featured_Listingsss'] );
    I tried placing a div class around it yet could not get it correct

    Code:
    echo ' <div class="h1">
              table_header ( $lang['Module_Featured_Listingsss'] );
              </div> ';

  4. #4
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, so a couple of things:

    Firstly, you haven't posted the code for you function table_header(), so I'm still unsure what that does. Perhaps you are using a framework, and it's a native function of that. I can guess that it creates a table header, and if that is the case it's does not need a h1 tag, since it doesn't add any semantic meaning to your document.

    Secondly a h1 tag is simply <h1></h1>, what you have described in your last post is a div with a class of h1. I would advise against using classes which mimic tag names as it can get confusing later, especially if other developers will need to use the code base.

    Now, depending on what your table_header() function actually does, you could perhaps try this:
    PHP Code:
    echo '<h1>' table_header($lang['Module_Featured_Listings']) . '<h1>'
    But my guess is you'll wind up with something like this:
    Code:
    <table>
        <h1>
            <thead>
                $lang['Module_Featured_Listings'] // whatever text/data is in this array element
            </thead>
        </h1>
        ... etc
    If that is the case, you'd end up with invalid HTML. Better to style the <thead> using CSS:
    Code:
    thead {
        font-weight: bold;
        font-size: 1.6em;
    }
    Or something similar.

    If you just want to print the contents of $lang['Module_Featured_Listings'] in a h1 tag, then this should work:
    PHP Code:
    echo '<h1>' $lang['Module_Featured_Listings'] . '<h1>'
    Hopefully that helps, but if not, you'll need to provide more information so I can understand your problem. The code for the table_header() function is essential, and also what it is you are trying to achieve exactly.

    Best,
    Mike

  5. #5
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Mickyginger, great to hear from you, thank you for your coding ideas, much appreciated.

    ok so:

    Code:
    echo '<h1>' . table_header($lang['Module_Featured_Listings']) . '<h1>';
    makes the whole box/table h1. but not the words/lang/title of the box

    Code:
    echo '<h1>' . $lang['Module_Featured_Listings'] . '<h1>';
    makes the words h1 but the title header/background has vanished ;(

    I experimented with combinations like:

    Code:
    echo  table_header (<h1>$lang['Module_Featured_Listingsss']<h1>)  ;
    yet no joy.

    the idea being to get the $lang/words to be h1

    maybe removed the $lang and just placing the words there...like

    Code:
    echo  table_header (<h1>My Title Words Here<h1>)  ;
    your help greatly appreciated

  6. #6
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hmm,

    So you still haven't posted the code for the table_header() function, and you haven't told me whether you are using a platform. Also I'm not sure what you mean by 'box/table'. Do you mean a table wrapped in a div?

    If you don't know where the table_header() function is in your code base, perhaps you could post the resultant HTML.

    I can't really help you unless I know what that function does. So please post the HTML you get from the following code:

    PHP Code:
    echo table_header($lang['Module_Featured_Listings']); 
    and we'll take it from there.

    M

  7. #7
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Mickyginger,

    good to hear from you ok best if you take a look at the site: http://house-for-sale-by-owner.com/

    just under the search on the first/home page you will see a blue header House For Sale by Owner

    that is what I am trying to give a h1 tag to

    If you still need any code, just tell em and I will try to locate what you want thank you

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Ray, somewhere in your code there is a function called table_header() and will probably start something like:
    PHP Code:
    function table_header($text) { 
    what Mickyginger is asking for is that function itself to be posted so we can see what the function does.
    What CMS system are you using or is it a custom job?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  9. #9
    SitePoint Enthusiast knojiyak's Avatar
    Join Date
    Oct 2013
    Posts
    66
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Please use this code.

    this code is perfect for echo in h1

    Code:
    echo '<h1>' . table_header($lang['Module_Featured_Listings']) . '<h1>';
    Happy to help you
    Last edited by spikeZ; Oct 27, 2013 at 10:16. Reason: sig removed

  10. #10
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by knojiyak View Post
    Please use this code.

    this code is perfect for echo in h1

    Code:
    echo '<h1>' . table_header($lang['Module_Featured_Listings']) . '<h1>';
    Happy to help you
    It appears the Ray has already tried that combination knojiyak! See post #5
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  11. #11
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello mickyginger, spikeZ, knojiyak, thank you for your time, and offerings

    I found this

    Code:
    // COMMON CONTENT TABLE HEADER
    // - this html code is added to all the content tables
    // as a header by using echo table_header('Name');
    function table_header ( $message )
    
     {
    
      global $cookie_template;
    
      $return = '
    
          <table border="0" cellpadding="0" cellspacing="0" width="100%">
           <tr>
            <td align="left" valign="top" height="31" width="13">
             <img src="' . URL . '/templates/' . $cookie_template . '/images/left_blocks.gif" alt="for_sale_by_owner" /><br />
            </td>
            <td class="table_header">
             ' . $message . '
            </td>
            <td align="right" valign="top" height="31" width="8">
             <img src="' . URL . '/templates/' . $cookie_template . '/images/right_blocks.gif" alt="house_for_rent" /><br />
            </td>			
           </tr>
    
           <tr>
            <td class="line_white_left" >
             <img src="' . URL . '/templates/' . $cookie_template . '/images/x.gif" alt="home_for_sale" height="1" width="1" />
            </td>
            <td valign="top" align="left">
    
             <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
               <td align="left" width="100%">
      	    <br />
    
         ';
    
      return $return;
    
     }
    
    // COMMON CONTENT TABLE FOOTER

  12. #12
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    ok, change it too:
    (note the <h1> around the $message variable)
    PHP Code:
    // COMMON CONTENT TABLE HEADER
    // - this html code is added to all the content tables
    // as a header by using echo table_header('Name');
    function table_header $message )

     {

      global 
    $cookie_template;

      
    $return '

          <table border="0" cellpadding="0" cellspacing="0" width="100%">
           <tr>
            <td align="left" valign="top" height="31" width="13">
             <img src="' 
    URL '/templates/' $cookie_template '/images/left_blocks.gif" alt="for_sale_by_owner" /><br />
            </td>
            <td class="table_header">
             <h1>' 
    $message '</h1>
            </td>
            <td align="right" valign="top" height="31" width="8">
             <img src="' 
    URL '/templates/' $cookie_template '/images/right_blocks.gif" alt="house_for_rent" /><br />
            </td>            
           </tr>

           <tr>
            <td class="line_white_left" >
             <img src="' 
    URL '/templates/' $cookie_template '/images/x.gif" alt="home_for_sale" height="1" width="1" />
            </td>
            <td valign="top" align="left">

             <table width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
               <td align="left" width="100%">
              <br />

         '
    ;

      return 
    $return;

     }

    // COMMON CONTENT TABLE FOOTER 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  13. #13
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, so we got to the bottom of it

    On a side note, I'm not sure a table is the correct markup for this data. Should it not be an unordered list? And if it is a table, a thead seems to be more appropriate than a h1 tag wrapped in a td?

    Just a thought...

  14. #14
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by mickyginger View Post
    Ok, so we got to the bottom of it

    On a side note, I'm not sure a table is the correct markup for this data. Should it not be an unordered list? And if it is a table, a thead seems to be more appropriate than a h1 tag wrapped in a td?

    Just a thought...
    Looking at the source code and the function I would have to agree with you MG. An H1 should be the main heading on your page and that isn't tabular data in a semantic sense.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  15. #15
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello spikeZ, and mickyginger Thank you for your patience, and for the code to create what I was looking for.

    Yes I will not use a h1, maybe a h4

    thank you, and very best wishes

  16. #16
    SitePoint Enthusiast knojiyak's Avatar
    Join Date
    Oct 2013
    Posts
    66
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Please try this one

    PHP Code:
    <?PHP $x "Hello"?>
    <h1><?=$x?></h1>

  17. #17
    SitePoint Addict
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    382
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Don't use
    Code:
    <?=$x?>
    to echo php variables, it is dependent on server settings. Use
    Code:
    <?php echo $x ?>
    But you should read the thread fully, as this isn't very useful in this instance.


Bookmarks

Posting Permissions

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