This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Different vertical results template based on groups

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Different vertical results template based on groups

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #54931
    apbalice71apbalice71
    Participant

    Hi, we are using the vertical results template and the results are in groups. Is it possible to have a different template depending on the group names or modify the vertical.php so that it will show differently if we add a condition based on the group name?

    #54934
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    In theory yes, but definitely needs some custom work.

    If it’s only CSS classes and nothing major, then I recommend using the group-header.php template file, where you can do some conditional checks via the $group_class, $group_url and $group_name variables.

    If something more complex, then within the vertical.php you also have access to those variables, they are passed on, so you can do conditional checks against the $group_class, $group_url and $group_name variables too.

    Based on that you could create more files like vertical1.php, vertical2.php etc.. and do logics like:

    if ( $group_name === 'Group name 1' ) {
    	require_once 'vertical1.php';
    } else if ( $group_name === 'Group name 2' ) {
    	require_once 'vertical2.php';
    } else {
    	require_once 'vertical_default.php';
    }

    ..altough I’m not sure if the variables will be passed on to the required files.

    Alternatively you can do the whole logic in the vertical.php file directly too:

    <?php if ( $group_name === 'Group name 1' ): ?>
    	<div>...</div>
    <?php elseif ( $group_name === 'Group name 2' ): ?>
    	<div>...</div>
    <?php else: ?>
    	<div>...</div>
    <?php endif; ?>
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.