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,

echo table_header ( $lang['Module_Featured_Listings'] );

all help greatly appreciated :slight_smile:

What does your table_header function do? Can you post the code for it?

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


echo table_header ( $lang['Module_Featured_Listingsss'] );

I tried placing a div class around it yet could not get it correct

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

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:


echo '<h1>' . table_header($lang['Module_Featured_Listings']) . '<h1>';

But my guess is you’ll wind up with something like this:


<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:


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:


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

Hello Mickyginger, great to hear from you, thank you for your coding ideas, much appreciated.

ok so:

echo '<h1>' . table_header($lang['Module_Featured_Listings']) . '<h1>';  

makes the whole box/table h1. but not the words/lang/title of the box :frowning:

echo '<h1>' . $lang['Module_Featured_Listings'] . '<h1>';  

makes the words h1 :slight_smile: but the title header/background has vanished ;(

I experimented with combinations like:

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

echo  table_header (<h1>My Title Words Here<h1>)  ;

your help greatly appreciated :slight_smile:

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:


echo table_header($lang['Module_Featured_Listings']);

and we’ll take it from there.

M

Hello Mickyginger,

good to hear from you :slight_smile: 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 :slight_smile:

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

Ray, somewhere in your code there is a function called table_header() and will probably start something like:


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?

Please use this code.

this code is perfect for echo in h1

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

Hello mickyginger, spikeZ, knojiyak, thank you for your time, and offerings :slight_smile:

I found this :slight_smile:

// 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

ok, change it too:
(note the <h1> around the $message variable)


// 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

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.

Hello spikeZ, and mickyginger :slight_smile: 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 :slight_smile:

Please try this one

<?PHP $x = "Hello"; ?>
<h1><?=$x?></h1>

Don’t use

<?=$x?>

to echo php variables, it is dependent on server settings. Use

<?php echo $x ?>

But you should read the thread fully, as this isn’t very useful in this instance.