Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAaron Grant
1,065 PointsI have a question about the teachers notes.
It says that we are supposed to replace the function get_item_id with the code
<? php
function get_item_html($id,$item) {
$output = "<li><a href='details.php?id="
. $id . "'><img src='"
. $item["img"] . "' alt='"
. $item["title"] . "' />"
. "<p>View Details</p>"
. "</a></li>";
return $output;
}
What I want to know is where in the project are we supposed to do that.
Jacob Mishkin
23,118 PointsAs stated in the video, I think around 1:45, the teacher create a functions.php file. I would go back and watch the video starting around that point or from the beginning.
1 Answer
Sergey Podgornyy
20,660 PointsAaron, you could replace your code in index.html, for example, using function get_item_html
. It will be much clear:
<?php
include("inc/data.php");
include("inc/functions.php");
$pageTitle = "Personal Media Library";
$section = null;
include("inc/header.php"); ?>
<div class="section catalog random">
<div class="wrapper">
<h2>May we suggest something?</h2>
<ul class="catalog">
<?php
$random = array_rand($catalog,4);
foreach($random as $id){
echo get_item_html($id,$catalog[$id]);
}
?>
</ul>
</div>
</div>
<?php include("inc/footer.php"); ?>
If you are intresting, you can see, how I realized this project here.
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 Pointsedited code for formatting