2

The {exp:bmi_favorite:list_ids entry_type="recipe" site_id="1"} outputs 18|19 to be passed to the entry_id parameter. It does not work, unless I manually add the 18|19 into the entry_id, like entry_id="18|19". That leads me to believe my module function (list_ids) is running after the exp:channel:entries tag. Is it possible to run list_ids first, without having to tweak the settings for the template the code is in?

I also tried changing the single quotes to double quotes and that did not change anything.

{exp:channel:entries
    channel="recipes"
    entry_id='{exp:bmi_favorite:list_ids entry_type="recipe" site_id="1"}'
}

    <h2>{title}</h2>

{/exp:channel:entries}


public function list_ids()
{
    $entry_type = $this->EE->TMPL->fetch_param('entry_type', false);

    if($entry_type == false)
        return 'Please provide valid entry_type';

    $site_id = $this->EE->TMPL->fetch_param('site_id', '1');

    $where_data = array(
        'site_id'       =>  $site_id,
        'user_id'       =>  $this->EE->session->userdata('member_id'),
        'entry_type'    =>  $entry_type,  
    );

    $query = $this->EE->db->where($where_data)->get('bmi_favorite');

    if($query->num_rows == 0)
        return false;

    $i = 1;
    $output = '';

    foreach($query->result() as $row):
        $output .= $row->entry_id;
        $i++;

        if($i <= $query->num_rows)
            $output .= '|';
    endforeach;

    return $output;
}

UPDATE: I added parse='inward' to the end of my list_ids template tag, that did the trick, but I'd like it to do that without the user having to put parse='inward' themselves, is that possible or the user will always have to append parse="inward" onto my module tag?

1

1 Answer 1

4

If you add parse="inward" to your channel entries tag parameters, it will force module tags inside your parameters to be parsed before the channel entries tag.

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.