• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

Make two lines of php print one line..

I have a snippet of PHP code that does what I want except it prints on two lines instead of one. It is necessary for it to print on one line. PHP 5.3. any suggestions on how to accomplish this?


<div id="footer" class="c-b">
      <div class="footer-inner">
        <?php if ($page['footer']): print render($page['footer']); endif; ?>
        <div class="c-b"></div>
      </div>
      <div id="footer-message">
        <div class="footer-inner">
              <div id="footer"> &copy 2012. All Rights Reserved. <?php print $footer_message . $footer ?></div>
              <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>
          <?php print $feed_icons; ?>
        </div>
      </div> <!-- /footer-message -->
    </div> <!-- /footer -->
0
jimmylew52
Asked:
jimmylew52
  • 8
  • 3
  • 3
  • +2
4 Solutions
 
käµfm³d 👽Commented:
To which "lines" are you referring? Anything contained within a <div> is going to be on its own line by default because <div> automatically gets a new line beneath it when rendered to the screen. This is because it is a block element. If you change the display property to inline or inline-block, then you can override this default behavior.

Is it the <div>s you are referring to?
0
 
jimmylew52Author Commented:
These two lines need to print as one.

 <div id="footer"> &copy 2012. All Rights Reserved. <?php print $footer_message . $footer ?></div>
              <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>
          <?php print $feed_icons; ?>

Tried changing to

 <div id="footer"> &copy 2012. All Rights Reserved.</div> <?php print $footer_message . $footer ?>
              <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>
          <?php print $feed_icons; ?>

but got the same result.
0
 
käµfm³d 👽Commented:
This is because of the <div>'s default behavior that I mentioned above. The stuff printed by the PHP is outside of the first <div>, so it will naturally fall on a new line unless you override the default display behavior of the <div>. For more information:  http://www.webdesignfromscratch.com/html-css/css-block-and-inline/
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jimmylew52Author Commented:
Looked like <a pr <span might work but they did not. I guess I do not understand.
0
 
Julian HansenCommented:
I don't know if this is helpful but this is your code without styling or other items of code
<!doctype html>
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
$page = array('footer' => 'Some footer text goes here');
$footer = "Some footer text goes here";
$footer_message = "Some additional footer text goes here";
?>
<div id="footer" class="c-b">
  <div class="footer-inner">
<?php if ($page['footer']): print $page['footer']; endif; ?>
    <div class="c-b"></div>
</div>
    <div id="footer-message">
      <div class="footer-inner">
        <div id="footer"> &copy 2012. All Rights Reserved. <?php print $footer_message . $footer ?></div>
        <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>
      </div>
    </div> <!-- /footer-message -->
</div> <!-- /footer -->
</body>
</html>

Open in new window

Which produces the following output
 Some footer text goes here
© 2012. All Rights Reserved. Some additional footer text goes hereSome footer text goes here

Open in new window

If this is not what you want then you have to look at the structure of your text. Maybe post back
a) What you are getting
b) What you would like
0
 
fourckCommented:
If thesolution provided by Julian does not work, you should verify the values of ($footer_message and  $footer) that does not contain inside some <div> or <p> tags  .....

i suggest to post the footer output that you are getting (view source) to be able to help you in a better way.

Good Luck!
0
 
Lukasz ChmielewskiCommented:
How about
 <div id="footer"><?php print "&copy 2012. All Rights Reserved.".$footer_message . $footer ?></div>
              <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>
          <?php print $feed_icons; ?>

Open in new window

0
 
jimmylew52Author Commented:
Here is the HTML  and the out put on the web site.

<html class="js" dir="ltr" version="XHTML+RDFa 1.0" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/1999/xhtml/vocab">
<body class="html front not-logged-in two-sidebars page-node">
<div id="skip-link">
<div id="header">
<div id="front-page-wrapper">
<div id="page">
<div id="footer" class="c-b">
<div class="footer-inner">
<div id="footer-message">
<div class="footer-inner">
<div id="footer">© Systrends 2012. All Rights Reserved.  </div>
<a class="pt_logo" target="_blank" href="http://premiumcmsthemes.com"></a>
<a class="feed-icon" title="Subscribe to www.systrends.com RSS" href="/?q=rss.xml">
</div>
</div>
</div>
</body>
</html>
webpage.doc
0
 
Julian HansenCommented:
Ok that outputs
© Systrends 2012. All Rights Reserved. 

Open in new window

What do you want it to output?
NB your last anchor is not closed
<a class="feed-icon" title="Subscribe to www.systrends.com RSS" href="/?q=rss.xml"> <== no closing </a>

Open in new window

0
 
jimmylew52Author Commented:
Roads_Roads

That change and deleting the line

 <a href="http://premiumcmsthemes.com" target="_blank" class="pt_logo"></a>

works on the web page but gives the following errors:

Notice: Undefined variable: footer_message
Notice: Undefined variable: footer
0
 
jimmylew52Author Commented:
julianH

Required output

© My Company 2012. All Rights Reserved.   (Feed_Icon)

New HTML with current changes:

<html class="js" dir="ltr" version="XHTML+RDFa 1.0" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/1999/xhtml/vocab">
<body class="html front logged-in two-sidebars page-node toolbar toolbar-drawer admin-menu" style="padding-top: 30px;">
<div id="skip-link">
<div id="overlay-disable-message" class="clearfix">
<div id="toolbar" class="toolbar overlay-displace-top clearfix toolbar-processed">
<div id="header">
<div id="front-page-wrapper">
<div id="page">
<div id="footer" class="c-b">
<div class="footer-inner">
<div id="footer-message">
<div class="footer-inner">
<div id="footer">
© My Company 2012. All Rights Reserved.
<a class="feed-icon" title="Subscribe to www.systrends.com RSS" href="/?q=rss.xml">
</div>
</div>
</div>
</div>
<div id="admin-menu" class="admin-menu-site-systrends7-systrends-com overlay-displace-top admin-menu-processed">
</body>
</html>
0
 
Julian HansenCommented:
put the <a class="feed-icon"...> onto the same line as the My Company 2012 and check your styling that you are not styling it to be of type block.
0
 
Lukasz ChmielewskiCommented:
Does your <a> tag have display: inline; value in css file ?
0
 
jimmylew52Author Commented:
put the <a class="feed-icon"...> onto the same line as the My Company 2012 and check your styling that you are not styling it to be of type block.   ---  Done

No change

Does your <a> tag have display: inline; value in css file ?    ---

not shure what you're asking but I don't think so. Here is the code.

<div id="footer" class="c-b">
      <div class="footer-inner">
        <?php if ($page['footer']): print render($page['footer']); endif; ?>
        <div class="c-b"></div>
      </div>
      <div id="footer-message">
        <div class="footer-inner">
              <div id="footer"><?php print "&copy Systrends 2012. All Rights Reserved.  " . $footer_message . $footer ?> <?php print $feed_icons; ?></div>
             </div>
      </div> <!-- /footer-message -->
    </div> <!-- /footer -->
0
 
Lukasz ChmielewskiCommented:
The code

<?php print $feed_icons; ?>

Is the second line, right ?
You have to see what's inside $feed_icons variable and add a styling to it in css file with
display: inline;

Can you please put the code with rss back on page, so we can see it online ?
0
 
jimmylew52Author Commented:
Thanks Roads_Roads but there is no need.  I have taken what everyone has suggested and some I found on other sources and determined that the code  only need to be simplified some more. I replaced:

<div id="footer"><?php print "&copy Systrends 2012. All Rights Reserved.  " . $footer_message . $footer ?> <?php print $feed_icons; ?></div>

With:

<?php print "&copy Systrends 2012. All Rights Reserved.  " ?> <?php print $feed_icons; ?>

and all works perfectly. The <dvi had everything messed up.

My most heart felt thanks to everyone that helped. I can enjoy my weekend now.
0
 
jimmylew52Author Commented:
Took many minds to get what needed to be done pounded into my brain.


Thanks again to everyone.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 8
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now