I don't want to have to create 4 different routes with one per search
parameter and the logic to call the correct route based off how many
search parameters there are.
I can't create a single route with the 4 parameters because they are
not all required and will return errors in the wheels framework when
the url looks like somepage///2/3 when they only chose the last
parameter for their search.
I was thinking of maybe writing some logic to loops through the search
params and put it into a session variable i can pass through while
they are paging.
I just don't see an easy way.
Suggestions.
/somecontroller/someaction?page=2&sort=foo
/somecontroller/someaction?productClass=3
pretty URLs are nice, but I'd say ugly URL params would be the way to
go, if you don't want to work out some routing logic.
> --
> You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
> To post to this group, send email to cfwh...@googlegroups.com.
> To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
>
>
--
Josh
Anyone else have a way around this.
On Apr 7, 12:57 pm, joshua clingenpeel <joshua.clingenp...@gmail.com>
wrote:
in routes.cfm:
addRoute(name="newRequest", pattern="/request/foo/[key]",
controller="projects", action="show");
addRoute(name="newRequest", pattern="/request/bar",
controller="projects", action="new");
In my view template, I created a #linkTo(route="newRequest") and it
generated a link to /request/bar - then created a
#linkTo(route="newRequest",key=12345)# and it generated a link to
/request/foo/12345. It worked as well when the pattern matched more
closely (/request/foo/[key] and also /request/foo).
This looks to be a viable option.
--
Josh
I have 4 input fields - none of them are required but will filter the
query down if a value is input.
Create a route like this addRoute(name="newRequest", pattern="/request/
[zip]/[city]/[state]/[county]/[page]", controller="zipcodes",
action="index");
Create
paginationLinks(route="newRequest",zip="",city="",state="",county="");
The issue is when a user inputs a zip and a county the url that is
created is /request/89131///Clark/3 this generate an error because of
there being no values for city and state.
Now this could be several different combinations so i don't think
creating a route for each combination is feasible.
On Apr 7, 3:20 pm, joshua clingenpeel <joshua.clingenp...@gmail.com>
wrote:
> Since I'm getting into custom routes for a large app I'm working on, I
> just messed around with multiple routes with the same name but
> different patterns and controller/action combos:
>
> in routes.cfm:
>
> addRoute(name="newRequest", pattern="/request/foo/[key]",
> controller="projects", action="show");
> addRoute(name="newRequest", pattern="/request/bar",
> controller="projects", action="new");
>
> In my view template, I created a #linkTo(route="newRequest") and it
> generated a link to /request/bar - then created a
> #linkTo(route="newRequest",key=12345)# and it generated a link to
> /request/foo/12345. It worked as well when the pattern matched more
> closely (/request/foo/[key] and also /request/foo).
>
> This looks to be a viable option.
>
>
>
> On Wed, Apr 7, 2010 at 11:29 AM, Per Djurner <per.djur...@gmail.com> wrote:
> > Have you tried creating multiple routes but naming them the same?
>
> > On Wed, Apr 7, 2010 at 4:25 PM, cbchumley <cbchum...@gmail.com> wrote:
> >> I have looked over the discussions regarding how to handle pagination
> >> and my issue is that if I have a paginated display where I am also
> >> allowing the user to search with 4 different parameters - what is the
> >> best way to handle this.
>
> >> I don't want to have to create 4 different routes with one per search
> >> parameter and the logic to call the correct route based off how many
> >> search parameters there are.
>
> >> I can't create a single route with the 4 parameters because they are
> >> not all required and will return errors in the wheels framework when
> >> the url looks like somepage///2/3 when they only chose the last
> >> parameter for their search.
>
> >> I was thinking of maybe writing some logic to loops through the search
> >> params and put it into a session variable i can pass through while
> >> they are paging.
>
> >> I just don't see an easy way.
>
> >> Suggestions.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
> >> To post to this group, send email to cfwh...@googlegroups.com.
> >> To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/cfwheels?hl=en.
No good?
args = StructNew();
args.route = "newRequest";
if (params.state IS NOT "")
args.state = params.state
paginationLinks(argumentCollection=args);
Does that help at all?
On Apr 8, 3:32 am, Per Djurner <per.djur...@gmail.com> wrote:
> Why are you inputting blank values?
> A better approach would be to build the arguments structure and pass
> it in to the function, something like this:
>
> args = StructNew();
> args.route = "newRequest";
> if (params.state IS NOT "")
> args.state = params.state
> paginationLinks(argumentCollection=args);
>
> Does that help at all?
>
On Apr 8, 7:14 am, Chris Peters <ch...@clearcrystalmedia.com> wrote:
> Search engines don't run searches, so why do you need SES?
>
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/cfwheels?hl=en.
>
> > > --
> > > Josh
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
<cffunction name="searchPagination">
<cfargument name="modelArg" default="" required="true" />
<cfargument name="whereArg" default="" required="true" />
<cfargument name="handleArg" default="" required="true" />
<cfargument name="orderArg" default="" required="false" />
<cfargument name="searchArgs" default="" required="false" />
<cfargument name="page" default="1" required="false" />
<cfargument name="perPage" default="25" required="false" />
<cfset var searchString = "" />
<cfset var searchResults = "" />
<!--- BUILD SEARCHSTRING --->
<cfset var args = duplicate(arguments.searchargs) />
<cfset var argnames = structKeyArray(args) />
<cfloop index="i" from="1" to="#ArrayLen(argnames)#">
<cfif args[argnames[i]] NEQ "">
<cfif len(trim(searchString)) EQ 0>
<cfset searchString = "#argnames[i]# LIKE
'%#args[argnames[i]]#%'" />
<cfelse>
<cfset searchString = searchString & " AND #argnames[i]#
LIKE '%#args[argnames[i]]#%'" />
</cfif>
</cfif>
</cfloop>
<cfif len(trim(searchString)) EQ 0>
<cfset searchString = arguments.whereArg />
</cfif>
<cfset searchResults =
model(arguments.modelArg).findAll(handle=arguments.handleArg,page=#arguments.page#,perPage=#arguments.perPage#,where=#searchString#,order=arguments.orderArg) /
>
<cfreturn searchResults />
</cffunction>
You would call this like:
<cfset zipcodes =
searchPagination(modelArg="zipcode",page=params.page,searchArgs=search,whereArg="zipcode
LIKE '%'",orderArg="zipcode",handleArg="zipcodes") />
Its flexible in that it allows you to pass in the model, page, search
arguments a default where argument, order by argument and a handle
argument for pagination.
If anyone needs better clarification on how to use it please let me
know.
<cffunction name="searchPagination">
<cfargument name="modelArg" default="" required="true" />
<cfargument name="whereArg" default="" required="true" />
<cfargument name="handleArg" default="" required="true" />
<cfargument name="orderArg" default="" required="false" />
<cfargument name="searchArgs" default="" required="false" />
<cfargument name="page" default="1" required="false" />
<cfargument name="perPage" default="25" required="false" />
<cfset var searchString = "" />
<cfset var searchResults = "" />
<!--- BUILD SEARCHSTRING --->
<cfif len(trim(arguments.searchArgs)) NEQ 0>
<cfset var args = duplicate(arguments.searchargs) />
<cfset var argnames = structKeyArray(args) />
<cfloop index="i" from="1" to="#ArrayLen(argnames)#">
<cfif args[argnames[i]] NEQ "">
<cfif len(trim(searchString)) EQ 0>
<cfset searchString = "#argnames[i]# LIKE
'%#args[argnames[i]]#%'" />
<cfelse>
<cfset searchString = searchString & " AND #argnames[i]#
LIKE '%#args[argnames[i]]#%'" />
</cfif>
</cfif>
</cfloop>
<cfif len(trim(searchString)) EQ 0>
<cfset searchString = arguments.whereArg />
</cfif>
<cfelse>
<cfset searchString = arguments.whereArg />
</cfif>
<cfset searchResults =
model(arguments.modelArg).findAll(handle=arguments.handleArg,page=#arguments.page#,perPage=#arguments.perPage#,where=#searchString#,order=arguments.orderArg) /
>
<cfreturn searchResults />
</cffunction>
> To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
I was but took Chris suggestion of just using query string in url.
So based off that came up with this global searchPagination routine
On Apr 11, 5:25 am, Per Djurner <per.djur...@gmail.com> wrote:
> That's just the model call though, I thought the problems you were
> having were also related to how to display the page links (with
> paginationLinks), no?
>