@ 2013-06-02T22:17:25Z <?php
// ---------------------- get article info ----------------------
$articles = simplexml_load_file('xml/shoparticles.xml'); // <-- loads local article database
//////(1)fetch multpiple article ids: $ids = array('article1' , 'article2', 'article3'); {
$output = '<div class="product">';
foreach ($articles->article as $article) {
//////(2)fetch multiple article ids: if (in_array($article['id'], $ids)) {
// fetch single article id: if ($article['id'] == 'article1') { **execute code**
if ($article['id'] == '10012037') {
// get the productType resource
$productType = simplexml_load_file($article->product->productType->attributes('xlink', true));
$output .= '<li class="clearfix" id="article_'.$article['id'].'"> <form method="post">';
$output .= '<img src="' . (string)$article->resources->resource->attributes('xlink', true) . ',width=560,height=560" alt="' . $article->name . '" class="preview" />';
// add a select with available sizes
$output .= '<select id="size-select" name="size">';
foreach($productType->sizes->size as $val) {
$output .= '<option value="'.$val['id'].'">'.$val->name.'</option>';
}
$output .= '</select>';
// add a list with available colors
$output .= '<ul class="colors" name="color">';
$freecolor = $article->product->restrictions->freeColorSelection;
$colorid = $article->product->appearance['id'];
foreach ($productType->appearances->appearance as $appearance) {
//single color articles
if ($appearance['id'] == intval($colorid) && $freecolor == "false") {
$output .= '<li value="'.$appearance['id'].'">' .
'<a href="javascript:void(0)" target="" title="'. $appearance->name .'">' .
'<img src="'. $appearance->resources->resource->attributes('xlink', true) .'" alt="'.
$appearance->name .'" name="'. $appearance->name .'" />
</a>
</li>';
break;
}
//multi color articles
if ($freecolor == "true") {
$output .= '<li value="'.$appearance['id'].'">' .
'<a href="javascript:void(0)" target="" title="'. $appearance->name .'">' .
'<img src="'. $appearance->resources->resource->attributes('xlink', true) .'" alt="'.
$appearance->name .'" name="'. $appearance->name .'" />
</a>
</li> ';
}
}
$output .= '</ul>';
//quantity
$output .= 'quantity: <input type="text" value="1" maxlenght="2" id="quantity" size="1" name="quantity">
<br /><br />';
//show price
$output .= 'price: <b>$'. $article->price->vatExcluded .'</b>';
//------hidden inputs for basket creation---------
//appearance/color
$output .= '<input type="hidden" ' . 'value="'. $article->product->appearance['id'] .'" id="appearance_'.$article['id'].'" name="appearance" />';
//article id
$output .= '<input type="hidden" value="'. $article['id'] .'" id="article_'.$article['id'].'" name="article" />';
//submits all info to basket
$output .= '<input type="submit" name="submit" value="Add to basket" style="float:right" /></form></li>';
} //if $article
} //for each $article
$output .= '</div>';
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit Warning: simplexml_load_file(): I/O warning : failed to load external entity "xml/shoparticles.xml" in /in/cF4kv on line 5
Warning: Attempt to read property "article" on bool in /in/cF4kv on line 10
Warning: foreach() argument must be of type array|object, null given in /in/cF4kv on line 10
Output for rfc.property-hooks Warning: simplexml_load_file(): I/O warning : failed to load external entity "xml/shoparticles.xml" in /in/cF4kv on line 5
Warning: Attempt to read property "article" on false in /in/cF4kv on line 10
Warning: foreach() argument must be of type array|object, null given in /in/cF4kv on line 10
This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
44.82 ms | 401 KiB | 8 Q