Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Twitter Bootstrap #214

Open
bogdaniel opened this issue Oct 31, 2016 · 1 comment
Open

Extend Twitter Bootstrap #214

bogdaniel opened this issue Oct 31, 2016 · 1 comment

Comments

@bogdaniel
Copy link

Hey guys, i'm new to fanta pager and i've been trying to extend the current functionality of twitter template to add data-attributes to the links. i was wondering is there a better way of doing this ?

class CustomFantaView extends TwitterBootstrap3Template
{

    public function page($page)
    {
        $text = $page;

        return $this->pageWithText($page, $text);
    }

    public function pageWithText($page, $text)
    {
        $class = null;

        return $this->pageWithTextAndClass($page, $text, $class);
    }

    private function pageWithTextAndClass($page, $text, $class)
    {
        $href = $this->generateRoute($page);

        return $this->linkLi($class, $href, $page, $text);
    }

    public function previousEnabled($page)
    {
        $text = $this->option('prev_message');
        $class = $this->option('css_prev_class');

        return $this->pageWithTextAndClass($page, $text, $class);
    }

    public function nextEnabled($page)
    {
        $text = $this->option('next_message');
        $class = $this->option('css_next_class');

        return $this->pageWithTextAndClass($page, $text, $class);
    }

    private function linkLi($class, $href, $text, $page)
    {
        $liClass = $class ? sprintf(' class="%s"', $class) : '';

        return sprintf('<li%s><a href="%s" data-page="%s">%s</a></li>', $liClass, $href, $text, $page);
    }
}
@cezzre
Copy link

cezzre commented May 23, 2017

Looks good to me.
You don't need to override every method, though.
Just the ones you want to customise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants