datadoit.com
|
| Posted: 06/13/2005, 10:31 AM |
|
PHP4; CCS 2.3
What's the correct syntax for removing multiple parameters using
CCRemoveParam() function?
Help says:
CCGetQueryString(CollectionName, RemoveParameters)
RemoveParameters = Array - Array of names which will be removed from the
resulting string.
How is this array to be formatted?
|
|
|
 |
Last Hero
|
| Posted: 06/14/2005, 12:31 AM |
|
Can you look in function definition?
CCRemoveParam($querystring, $ParameterName)
First parameter - Query String(string type), where you want remove parameter with name $ParameterName.
Only one parameter can be removed with this function.
Simple example:
$QueryString = "page1.php?a=1&b=2&c=3";
$NewQueryString = CCRemoveParam($QueryString, "b");
Now $NewQueryString == "page1.php?a=1&c=3"
|
|
|
 |
datadoit.com
|
| Posted: 06/14/2005, 7:05 AM |
|
<LastHero@forum.codecharge (Last Hero)> wrote in message
news:542ae87d77c791@news.codecharge.com...
> Can you look in function definition?
> CCRemoveParam($querystring, $ParameterName)
>
> First parameter - Query String(string type), where you want remove
> parameter
> with name $ParameterName.
> Only one parameter can be removed with this function.
>
> ---------------------------------------
'Function Definition' clearly states that the parameters that are to be
removed is in an Array. This leads me to believe that more than one
parameter can be removed at a time. I'd like to know the format of that
Array (comma separated list, semi-colon list, what?).
I've figured out a way around this by:
$QueryString = CCGetQueryString("QueryString", "");
$pg = CCRemoveParam($QueryString, "Param1");
$pg = CCRemoveParam($pg, "Param2");
However, -If- $ParameterName is really an Array of values, then that would
eliminate the three or more lines of code required to remove two or more
parameters.
|
|
|
 |
Last Hero
|
| Posted: 06/14/2005, 8:19 AM |
|
In you case can be used:
$QueryString = CCGetQueryString("QueryString", Array("Param1", "Param2"));
>However, -If- $ParameterName is really an Array of values, then that would
>eliminate the three or more lines of code required to remove two or more
>parameters.
Yes, you are right. But function name are CCRemoveParam, not CCRemoveParams :)
|
|
|
 |
DonB
|
| Posted: 06/14/2005, 10:20 AM |
|
Not sure what reference you are talking about. The function does a simple
preg_replace() ( for PHP) and Replace() (for ASP). Thus, the second
parameter cannot be an array, only a scalar value ( the name of one
parameter to be removed ).
Perhaps the documentation changed along the way and you have an outdated
version of it? I checked the online version and it's not described as an
array in therem which should be the most current definition.
--
DonB
http://www.gotodon.com/ccbth
"datadoit.com" <mike@datadoit.com> wrote in message
news:d8mo6u$l0k$1@news.codecharge.com...
> <LastHero@forum.codecharge (Last Hero)> wrote in message
>news:542ae87d77c791@news.codecharge.com...
> > Can you look in function definition?
> > CCRemoveParam($querystring, $ParameterName)
> >
> > First parameter - Query String(string type), where you want remove
> > parameter
> > with name $ParameterName.
> > Only one parameter can be removed with this function.
> >
> > ---------------------------------------
>
> 'Function Definition' clearly states that the parameters that are to be
> removed is in an Array. This leads me to believe that more than one
> parameter can be removed at a time. I'd like to know the format of that
> Array (comma separated list, semi-colon list, what?).
>
> I've figured out a way around this by:
>
> $QueryString = CCGetQueryString("QueryString", "");
> $pg = CCRemoveParam($QueryString, "Param1");
> $pg = CCRemoveParam($pg, "Param2");
>
> However, -If- $ParameterName is really an Array of values, then that would
> eliminate the three or more lines of code required to remove two or more
> parameters.
>
>
|
|
|
 |
datadoit.com
|
| Posted: 06/14/2005, 4:55 PM |
|
"DonB" <~ccbth~@gotodon.com> wrote in message
news:d8n3lf$tvt$1@news.codecharge.com...
> Perhaps the documentation changed along the way and you have an outdated
> version of it? I checked the online version and it's not described as an
> array in therem which should be the most current definition.
>
-------------------------
I hit F1 in CCS v2.3.whatever and did a lookup of "CCRemoveParam". Says
'Array'. Am I the only one with this special version of the help files? :)
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/14/2005, 5:05 PM |
|
Yes, looks like you are...
I just searched for "CCRemoveParam" and I see 6 topics. Two of them are "CCRemoveParam Function (PHP)" and they don't mention arrays at all.
Only the other function that you mentioned above "CCGetQueryString" refers to arrays.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
datadoit.com
|
| Posted: 06/14/2005, 6:26 PM |
|
"peterr" <peterr@forum.codecharge> wrote in message
news:542af70af4baa5@news.codecharge.com...
> Yes, looks like you are...
> I just searched for "CCRemoveParam" and I see 6 topics. Two of them are
> "CCRemoveParam Function (PHP)" and they don't mention arrays at all.
> Only the other function that you mentioned above "CCGetQueryString" refers
> to
> arrays.
> _________________
Yep, you're right. Myself and I were getting confused with ourselves.
I like Last Hero's suggestion of just making it a plural function
(CCRemoveParams). :)
Am I still stuck with using three lines of code to remove two or more
parameters, or is there a simpler, better way?
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/14/2005, 8:23 PM |
|
Sorry, I'm not too experienced with PHP and don't use those functions but maybe the 2nd post from Last Hero answers your question. If not then I guess you'd have to remove the parameters one at a time. Or maybe the support would have add'l suggestions.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
DonB
|
| Posted: 06/15/2005, 7:04 AM |
|
I wrote a PHP function to handle arrays of parameters. Just add it to your
Common.php or, as I do, put it in a separate php file that is referenced by
an 'include()' in Common.php. That will make it callable from anywhere in
your application.
Now you only need to write one line of code anywhere you need to remove
several parameters. For convenience, I made sure it handles the case where
there is NOT an array (in which case, it works like CCRemoveParam). My
function is called in this manner:
RemoveParamMult($querystring, $arrayofparams).
Here are the details:
http://www.gotodon.com/ccbth/Features/ViewKB.asp?KBID=2083
A side note, there seems to be a bug in CCRemoveParam(), at least to me.
The first parameter of a querystring CANNOT be removed by CCRemoveParam().
Only parameters that begin with "&" will be removed. Since the first one
begins with "?", it is ignored.
--
DonB
http://www.gotodon.com/ccbth
"datadoit.com" <mike@datadoit.com> wrote in message
news:d8o03i$in7$1@news.codecharge.com...
> "peterr" <peterr@forum.codecharge> wrote in message
>news:542af70af4baa5@news.codecharge.com...
> > Yes, looks like you are...
> > I just searched for "CCRemoveParam" and I see 6 topics. Two of them are
> > "CCRemoveParam Function (PHP)" and they don't mention arrays at all.
> > Only the other function that you mentioned above "CCGetQueryString"
refers
> > to
> > arrays.
> > _________________
>
> Yep, you're right. Myself and I were getting confused with ourselves.
>
> I like Last Hero's suggestion of just making it a plural function
> (CCRemoveParams). :)
>
> Am I still stuck with using three lines of code to remove two or more
> parameters, or is there a simpler, better way?
>
>
|
|
|
 |
DonB
|
| Posted: 06/15/2005, 2:42 PM |
|
I've been told by CCS support that CCRemoveParam() does work as it's
supposed to work. Evidently the querystring parameter is expected to NOT
include the "?" character, so if your page is
http://example.com/foobar.php?a=1&b=2&c=3
then the 'querystring' that CCRemoveParam() expects to see would be
a=1&b=2&c=3
so my example was flawed in the sense it treated the complete URL as the
querystring. In other words, the 'querystring' is actually supposed to be
everything AFTER the '?' in a URL.
--
DonB
http://www.gotodon.com/ccbth
"DonB" <~ccbth~@gotodon.com> wrote in message
news:d8pcgh$fsp$1@news.codecharge.com...
> I wrote a PHP function to handle arrays of parameters. Just add it to
your
> Common.php or, as I do, put it in a separate php file that is referenced
by
> an 'include()' in Common.php. That will make it callable from anywhere in
> your application.
>
> Now you only need to write one line of code anywhere you need to remove
> several parameters. For convenience, I made sure it handles the case
where
> there is NOT an array (in which case, it works like CCRemoveParam). My
> function is called in this manner:
>
> RemoveParamMult($querystring, $arrayofparams).
>
> Here are the details:
>
> http://www.gotodon.com/ccbth/Features/ViewKB.asp?KBID=2083
>
> A side note, there seems to be a bug in CCRemoveParam(), at least to me.
> The first parameter of a querystring CANNOT be removed by CCRemoveParam().
> Only parameters that begin with "&" will be removed. Since the first one
> begins with "?", it is ignored.
> --
> DonB
>
> http://www.gotodon.com/ccbth
>
>
> "datadoit.com" <mike@datadoit.com> wrote in message
>news:d8o03i$in7$1@news.codecharge.com...
> > "peterr" <peterr@forum.codecharge> wrote in message
> >news:542af70af4baa5@news.codecharge.com...
> > > Yes, looks like you are...
> > > I just searched for "CCRemoveParam" and I see 6 topics. Two of them
are
> > > "CCRemoveParam Function (PHP)" and they don't mention arrays at all.
> > > Only the other function that you mentioned above "CCGetQueryString"
> refers
> > > to
> > > arrays.
> > > _________________
> >
> > Yep, you're right. Myself and I were getting confused with ourselves.
> >
> > I like Last Hero's suggestion of just making it a plural function
> > (CCRemoveParams). :)
> >
> > Am I still stuck with using three lines of code to remove two or more
> > parameters, or is there a simpler, better way?
> >
> >
>
>
|
|
|
 |
|