Jump to content

Pagination create different markup for active link


hberg539
 Share

Recommended Posts

Hello,

i'm currently using this setup for my pagination:

				$results = $baustelle->children("limit=2");
				$pagination = $results->renderPager(array(
					'nextItemLabel' => "Next",
					'previousItemLabel' => "Prev",
					'listMarkup' => "<ul class='pagination mg-b-0'>{out}</ul>",
					'itemMarkup' => "<li class='page-item {class}'>{out}</li>",
					'linkMarkup' => "<a class='page-link' href='{url}'>{out}</a>",
					'currentItemClass' => "active"
				));
				echo $pagination;

PW generates the following output (see the html-comment <!-- -->):

    <li class="active MarkupPagerNavFirst MarkupPagerNavFirstNum">
        <a href="/test/"> <!-- different markup as in linkMarkup specified -->
            <span>
                1
            </span>
        </a>
    </li>
    <li class="MarkupPagerNavLastNum">
        <a class="page-link" href="/test/page2">
            2
        </a>
    </li>
    <li class="MarkupPagerNavNext MarkupPagerNavLast">
        <a class="page-link" href="/test/page2">
            Next
        </a>
    </li>

</ul>

Is this expected behaivor? How can i add the class "page-link" in the a-tag in the current active page?

Thanks!

Best regards,

Kevin

Edited by hberg539
Link to comment
Share on other sites

Hi Kevin! Welcome to the forums.

Add the "currentLinkMarkup" to your array, like this:

$results = $baustelle->children("limit=2");
$pagination = $results->renderPager(array(
  'nextItemLabel' => "Next",
  'previousItemLabel' => "Prev",
  'listMarkup' => "<ul class='pagination mg-b-0'>{out}</ul>",
  'itemMarkup' => "<li class='page-item {class}'>{out}</li>",
  'linkMarkup' => "<a class='page-link' href='{url}'>{out}</a>",
  'currentLinkMarkup' => "{out}",
  'currentItemClass' => "active"
));
echo $pagination;

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...