2

I am obfuscating URL's in my app (which is great), but I'd like to disable this for pagination URL's because I'd like the user to be able to enter whatever number they like.

Settings.cfm:

<cfset set(obfuscateURLs = true) />

Home.cfc (controller):

<cffunction name="home">

        <cfparam name="params.page" default="1" />

        <cfset linkList = model("link").findAll(
            select="linkTitle,linkPoints,linkID,linkAuthority,linkCreated,linkUpVoteCount,linkDownVoteCount,linkCommentCount,userName,userID",
            include="user", 
            order="linkPoints DESC",
            handle="linkListPaging",
            page=params.page,
            perPage=5
        ) />

    </cffunction>

Home.cfm (view)

<ul class="pagination">
            <cfoutput>
                #paginationLinks( 
                    route="paginateLatest", 
                    handle="linkListPaging",
                    page=1,
                    name="page", 
                    windowSize=5, 
                    prependToPage="<li>", 
                    appendToPage="</li>", 
                    classForCurrent="current"
                )#
            </cfoutput>
        </ul>

Can I do DeObfuscate on an as needed basis?

Thanks, Michael

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Michael Giovanni Pumo
  • 14,338
  • 18
  • 91
  • 140

1 Answers1

1

The setting to obfuscate params is an all-or-nothing deal. Just as you can't override this behavior for linkTo(), you cannot override it for paginationLinks() either.

I would suggest building a plugin as I bet there will be other developers out there who would want this in the future. There may be a way to tell the controller to not obfuscate/deobfuscate a parameter named page. You would need to update both how urlFor() works as well as how the controller deobfuscates as it handles incoming requests. You may also consider providing a configuration option to use set() to "blacklist" a set of params keys to never be obfuscated (with page being a default).

Chris Peters
  • 17,918
  • 6
  • 49
  • 65