Total newbe here, I have created a hook to run a php function, that function goes and curls a site and gives back an array of category_id and category_name. Which I want to display on my template page.
My template page, I am doing:
{foreach from=$categories item=items}
List : {$items.category_id} - {$items.category_name}<br>
{/foreach}
Now I want to take the category_id and pass it back to a new function (hook_get_titles) which will give back titles that are in that category. How can I pass the category_id back ?
function hook_get_categories($vars)
{
//Action
$url = 'some webpage';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLINFO_HEADER_OUT => true,
CURLOPT_HEADER => false,
));
$content = curl_exec($ch);
//$information = curl_getinfo($ch);
curl_close($ch);
$categories = json_decode($content, true);
return array("categories" => $categories);
}
add_hook('ClientAreaPage', 1, 'hook_get_categories');
function hook_get_titles($categories_id)
{
$url = 'some webpage/?categories_id='.$categories_id;
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLINFO_HEADER_OUT => true,
CURLOPT_HEADER => false
));
$content = curl_exec($ch);
curl_close($ch);
$titles = json_decode($content, true);
return array("titles" => $titles);
}
add_hook('ClientAreaPage', 1, 'hook_get_title');