Jump to content

Problem with rendering out css and images


pwired
 Share

Recommended Posts

Hi,

I have a problem with rendering out css and images.

First I have 4 css files that I want to render out like this:

<?php
        $file = "styles/$page->css1";
        if(is_file($config->paths->templates . $file)) {
          echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />";
        }

        $file = "styles/$page->css2";
        if(is_file($config->paths->templates . $file)) {
          echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />";          
        }

        $file = "styles/$page->css3";
        if(is_file($config->paths->templates . $file)) {
          echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />";          
        }

        $file = "styles/$page->css4";
        if(is_file($config->paths->templates . $file)) {
          echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />";          
        }

?>

When I go to page source I see they are all there but all are next to each other on 1 line.

How can I have them rendered out each one on it's own line ?

Same problem I have with rendering out pictures.

This is what I want to achieve:

<div class="wrapper">
    <div id="myGallery" class="spacegallery">
        <img src="images/spc0101.jpg" alt="" />
        <img src="images/spc0102.jpg" alt="" />
        <img src="images/spc0103.jpg" alt="" />
        <img src="images/spc0104.jpg" alt="" />
        <img src="images/spc0105.jpg" alt="" />
        <img src="images/spc0106.jpg" alt="" />
        <img src="images/spc0107.jpg" alt="" />
        <img src="images/spc0108.jpg" alt="" />
        <img src="images/spc0109.jpg" alt="" />
        <img src="images/spc0110.jpg" alt="" />
        <img src="images/spc0111.jpg" alt="" />
        <img src="images/spc0112.jpg" alt="" />
        <img src="images/spc0113.jpg" alt="" />
        <img src="images/spc0114.jpg" alt="" />
        <img src="images/spc0115.jpg" alt="" />
    </div>
</div>

When I try this:

<div class="wrapper">
    <div id="myGallery" class="spacegallery">

<?php
foreach($page->images as $image) {
echo "<img src='$image->url'>";
}
?>


    </div>
</div>

All picture urls are on 1 line and the part alt="" is missing

<img src='/zundapp/site/assets/files/1007/spc0101.jpg'><img src='/zundapp/site/assets/files/1007/spc0102.jpg'><img src='/zundapp/site/assets/files/1007/spc0103.jpg'><img src='/zundapp/site/assets/files/1007/spc0104.jpg'><img src='/zundapp/site/assets/files/1007/spc0105.jpg'><img src='/zundapp/site/assets/files/1007/spc0106.jpg'><img src='/zundapp/site/assets/files/1007/spc0107.jpg'><img src='/zundapp/site/assets/files/1007/spc0108.jpg'><img src='/zundapp/site/assets/files/1007/spc0109.jpg'><img src='/zundapp/site/assets/files/1007/spc0110.jpg'><img src='/zundapp/site/assets/files/1007/spc0111.jpg'><img src='/zundapp/site/assets/files/1007/spc0112.jpg'><img src='/zundapp/site/assets/files/1007/spc0113.jpg'><img src='/zundapp/site/assets/files/1007/spc0114.jpg'><img src='/zundapp/site/assets/files/1007/spc0115.jpg'>

How can I get all picture urls each on it's own line including the part alt=""

Thanks

Link to comment
Share on other sites

How can I have them rendered out each one on it's own line ?

By emitting a newline escape sequence at the end of your echo statement:

echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />\n";  
How can I get all picture urls each on it's own line including the part alt=""

For the new line, same thing as above. For the alt text:

<?php
foreach($page->images as $image) {
    echo "<img src='$image->url' alt='$image->description'>\n";
}
?>

Of course, the proper alt text will only be emitted if you or your editors actually enter an image description in the PW backend.

Also, I would advise to emit the images as an unordered list here. That's what they are semantically. You can remove the list bullets using CSS, of course.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...