show pictures

Status
Not open for further replies.

Kant

Member
I want to display the pictures from another list.

Which element plugin can you use for this?

With the Calc element plugin the filename is shown to me.

I use the following code for the query:
Code:
$mydb = FabrikWorker::getDbo(false, 3);
$myQuery = $mydb->getQuery(true);
$myQuery->select('bilder')->from('fahrzeuge')->where('id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
return $mydb->loadResult();
 
If you want to see the picture the calc has to create HTML code, something like
return '<img src="' . $mydb->loadResult() .'" style ="width:100px;">';
 
Yes. You'd have to modify the query to get the details from the repeat table we automatically create for multiple AJAX uploads, which is named <tablename>_repeat_<elementname>, so if your 'bilder' element was an AJAX upload ...

Code:
$myQuery->select('bilder')->from('fahrzeuge_bilder_repeat')->where('parent_id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
$results = $db->loadColumn();
$links = array[];
foreach ($results as $result) {
   $links[] = '<img src="' . $$result.'" />';
}
if (!empty($links)) {
   return '<ul><li>' . explode('</li><li>', $links) . '</li></ul>';
}
return '';

... which should render a UL of your links. Tweak that return to format them how you want, so to just separate them with <br /> ...

Code:
return explode('<br />', $links);

-- hugh
 
Unfortunately have a code error:

http://prntscr.com/iwy0oo

Code:
$mydb = FabrikWorker::getDbo(false, 3);
$myQuery=$mydb->getQuery(true);
$myQuery->select('bilder')->from('fahrzeuge_repeat_bilder')->where('parent_id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
$results = $mydb->loadColumn();
$links = array[];
foreach ($results as $result) {
   $links[] = '<img src="' . $$result.'" />';
}
if (!empty($links)) {
   return '<ul><li>' . explode('</li><li>', $links) . '</li></ul>';
}
return explode('<br />', $links);
 
Try this:

Code:
$mydb = FabrikWorker::getDbo(false, 3);
$myQuery=$mydb->getQuery(true);
$myQuery->select('bilder')->from('fahrzeuge_repeat_bilder')->where('parent_id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
$results = $mydb->loadColumn();
$links = array();
foreach ($results as $result) {
   $links[] = '<img src="' . $$result.'" />';
}
if (!empty($links)) {
   return '<ul><li>' . explode('</li><li>', $links) . '</li></ul>';
}
return explode('<br />', $links);

There was a typo in this line: $links = array();
 
Ooops, another typo. Remove the double $$ on $$result ...

Code:
$mydb = FabrikWorker::getDbo(false, 3);
$myQuery=$mydb->getQuery(true);
$myQuery->select('bilder')->from('fahrzeuge_repeat_bilder')->where('parent_id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
$results = $mydb->loadColumn();
$links = array();
foreach ($results as $result) {
   $links[] = '<img src="' . $result.'" style ="width:100px;"/>';
}
if (!empty($links)) {
   return '<ul><li>' . explode('</li><li>', $links) . '</li></ul>';
}
return explode('<br />', $links);

How do I create the sizes default of the pictures?

Just add whatever styling you want, as per Troester's suggestion. I've added setting w width the above code.

-- hugh
 
Oh, jeez, I must have been asleep when I wrote that code. OK ...

Code:
$mydb = FabrikWorker::getDbo(false, 3);
$myQuery=$mydb->getQuery(true);
$myQuery
   ->select('bilder')
   ->from('fahrzeuge_repeat_bilder')
   ->where('parent_id = ' . $mydb->quote('{vermietung___fahrzeug_id_raw}'));
$mydb->setQuery($myQuery);
$results = $mydb->loadColumn();
$links = array();

foreach ($results as $result) {
   $links[] = '<img src="' . $result.'" style ="width:100px;"/>';
}

if (!empty($links)) {
   return '<ul><li>' . implode('</li><li>', $links) . '</li></ul>';
}

return '';

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top