Jump to content
Killersites Forums

Xhtml verification


Recommended Posts

Good morning and merry Christmas to you all. I have eventually finished the paypal course that I purchased from Killer sites and everything works, I also understand upto a point what I have been taught. Two slight problems. The only way I can find to insert an alternate text to the images is in the templates page and then only one appears everywhere so I had to make it a catch all of product image which although it verifies is less than ideal. Also I am struggling to come to grips with showing the products on more than one row. every time I add a product it goes next to the previous and eventually everything distorts.

Kindest regards

David

Link to post
Share on other sites

Alternate text issue:

 

I personally haven't worked through this course, so I'm using the finished sample code that was included with the course. You should have a function named "render_products_from_XML()" within "templates.php" in the functions folder. Should look roughly like this:

 

If you change this line (that renders the product image): "$product->img" to

 


 

That should add an alt attribute that matches the product title. Alternately, you could add an additional row in your XML file specifically for the alt attribute on the product images, but then you'll also need to write all the PHP to get that information from the XML file.

Link to post
Share on other sites

Showing products in more than one row:

 

Well, you'll probably need to modify your render_products_from_XML() function again. Basically, you need to add a counter to your loop that displays each of the products, and add one to it every time a product gets displayed. Once the loop hits a certain number (the number of items you want displaying in a row - my example defaults to 3) it closes the

(table row) and adds a new one.

 

Something like this:

 

>function render_products_from_XML() {
   // starts the product table
   $output = "</pre>
<table class="products">";

   // sets loop to 0
   $i = 0;

   // starts looping through products
   foreach (get_xml_catalog() as $product) {
       $output .= '


' . $product->title . '


' . $product->description . '


                       $' . $product->price .'


Add to Cart








';

       // checks the loop. If it's >= 2 (indicating that it's looped 3 times)...
       if ($i >= 2){
           // start new row
           $output .= "";
           // reset loop
           $i = 0;
       }
       // if not, add one to the loop
       else
           $i++;
   }

   // adds in extra blank s if there aren't enough products to completely 
   // fill up the table
   if ($i == 1)
       $output .= '';
   else if ($i == 2)
       $output .= '';

   // finishes table    
   $output .= '</table>';<br><br>   return $output

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...