0

I've got articles with single images or gallery created with SIGE on my website, I need to load metadata for each image from mysql database, is that possible?

1 Answer 1

1

It is definitely possible, if you mean the meta keywords. AFAIK, the "Related Articles"-Plugin uses the meta keywords and has a corresponding database-call in its code. You can find the code for that in:

/modules/mod_related_items/helper.php

you want to look at lines 53-83 (at least in my version). The important part (and the answer to your question, should look something like that:

// get the database and an array of the existing article_ids
$db = JFactory::getDbo();
$article_ids = array() // tbh I don't recall the exact JFactory call you'd
// have to call, but you can probably work that one out.

// all the following is taken from mod_related_articles
foreach ($article_ids as $id) {
    $query->select('metakey')
            ->from('#__content')
            ->where('id = ' . (int) $id);
    $db->setQuery($query);
}

// now trim and explode the result of the query
$metakey = trim($db->loadResult());
$keys = explode(',', $metakey);
$likes = array();

foreach ($keys as $key)
{
    $key = trim($key);
    if ($key) {
        $likes[] = $db->escape($key);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.