Pagination Links Bootstrap 4

95 views
Skip to first unread message

Risto

unread,
Nov 23, 2016, 1:38:16 PM11/23/16
to CFWheels
Hi,

I almost have my pagination working for bootstrap 4 except...

I don't see any parameter to add a class in the actual anchor. Sometimes my brain scrambles when I see all the parameters for
paginationlinks - http://docs.cfwheels.org/v1.4/docs/paginationlinks

Does anyone see a way to add a class in the anchor itself (not prepend or append)? attached is an image with the class that needs to be added circled.

If not, maybe in the next cfwheels version a new parameter anchorclass could be added.

Thanks








Capture.PNG

Andrew Bellenie

unread,
Nov 23, 2016, 1:40:36 PM11/23/16
to ColdFusion on Wheels
Have you tried adding class="page-link" to paginationLinks()? All parameters are passed through to linkTo()



--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Risto

unread,
Nov 23, 2016, 2:44:38 PM11/23/16
to CFWheels
Andy,

Thank you. Works like a charm. It's funny when you stare at all these parameters and then somebody points out the obvious.
That's why I love this list. I found one last issue preventing it from working 100%. Active class.

I have linkToCurrentPage=true and classForCurrent="active". Problem is class goes on <a> but it needs to go on <li>

I guess I could do it with javascript unless anyone can come up with a hack.

Thanks













On Wednesday, November 23, 2016 at 1:40:36 PM UTC-5, Andrew Bellenie wrote:
Have you tried adding class="page-link" to paginationLinks()? All parameters are passed through to linkTo()


On 23 November 2016 at 18:38, Risto <ck.web...@gmail.com> wrote:
Hi,

I almost have my pagination working for bootstrap 4 except...

I don't see any parameter to add a class in the actual anchor. Sometimes my brain scrambles when I see all the parameters for
paginationlinks - http://docs.cfwheels.org/v1.4/docs/paginationlinks

Does anyone see a way to add a class in the anchor itself (not prepend or append)? attached is an image with the class that needs to be added circled.

If not, maybe in the next cfwheels version a new parameter anchorclass could be added.

Thanks








--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.

Andrew Bellenie

unread,
Nov 23, 2016, 3:30:49 PM11/23/16
to ColdFusion on Wheels
I don't think it's possible.

An alternative is to use the pagination() struct and build the links yourself.

To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+unsubscribe@googlegroups.com.

Risto

unread,
Nov 23, 2016, 3:35:33 PM11/23/16
to CFWheels
That's a good idea. I'll let you know how it turns out.

MvdO79

unread,
Feb 18, 2020, 7:17:11 PM2/18/20
to CFWheels
Is there already a solution for this:

"I have linkToCurrentPage=true and classForCurrent="active". Problem is class goes on <a> but it needs to go on <li>"

Bootstrap is pretty common used so that would be great.

Op woensdag 23 november 2016 21:35:33 UTC+1 schreef Risto:

Risto

unread,
Feb 19, 2020, 12:48:30 PM2/19/20
to CFWheels
Hi,

I've been through so many iterations of bootstrap pagination over the years I don't even remember anymore. 
What I can tell you is this is what I'm currently using with my bootstrap 4 templates and it works great.

I put this in /global/functions.cfm

    <cffunction name="b4PaginationLinks" returntype="string">
       <cfscript>
           var loc = {};

            loc.paginationArgs = Duplicate(arguments);

            loc.paginationArgs.prepend = '<ul class="pagination">';
           loc.paginationArgs.append = '</ul>';
           loc.paginationArgs.prependToPage='<li class="page-item">'
           loc.paginationArgs.appendToPage = '</li>';
            loc.paginationArgs.classForCurrent = "page-link active";
           loc.paginationArgs.class="page-link";
           loc.paginationArgs.linkToCurrentPage = false;
           loc.paginationArgs.anchorDivider = "";
           loc.paginationArgs.linkToCurrentPage = true;
           loc.paginationArgs.encode="false";
           loc.paginationLinks = paginationLinks(argumentCollection=loc.paginationArgs);
           loc.paginationLinks = replaceNoCase(loc.paginationLinks, '<li class="page-item"><a class="page-link active"',
               '<li class="page-item active"><a class="page-link"', "all");

        </cfscript>
       <cfreturn loc.paginationLinks>
</cffunction>

and this in my index pages:
 <cfoutput>#b4PaginationLinks(route="Users",windowSize=2,alwaysShowAnchors=true)#</cfoutput>

Keep in mind I'm not using plain bootstrap so my classes above might be custom I don't remember. It's easy to adjust in the function if you need to change the class to match your template.


MvdO79

unread,
Feb 19, 2020, 1:21:21 PM2/19/20
to CFWheels
Thanks Risto, that's an example I was looking for, are you ok to suggest this (or let me suggest this) as an additional code example on the bottom of this page:


Thanks again!

Op woensdag 19 februari 2020 18:48:30 UTC+1 schreef Risto:
Reply all
Reply to author
Forward
Message has been deleted
0 new messages