Custom module rawurlencode with CreateLink (cause by array)

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
Eric Pesser
Forum Members
Forum Members
Posts: 27
Joined: Mon Oct 13, 2008 8:59 am
Location: Stavelot / Belgium

Custom module rawurlencode with CreateLink (cause by array)

Post by Eric Pesser »

Hi,

I currently have an error in a custom module.

I think CMSM API don't support arrays while generating urls.

My urls are pagination url from a search page. All links should be copied and so all parameters are needed.

Here is the call :

Code: Select all

$item->url = $this->CreateLink($id, 'my_list', $returnid, '', array_merge($params, array('pagination_page_number' => $item->index, 'pagination_page_limit' => $params['pagination_page_limit'])), '', true);
I've added a select/multiple in the search panel. So that now, $params contain an array.

This array causes a rawurlencode() warning because this funtion is waiting a string.

[removed by moderator]
User avatar
guro
Power Poster
Power Poster
Posts: 985
Joined: Thu Apr 26, 2012 8:38 pm
Location: Ramenskoe

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by guro »

You may serialize your array before use array_merge. And unserialize in your module after processing cms core.
User avatar
Eric Pesser
Forum Members
Forum Members
Posts: 27
Joined: Mon Oct 13, 2008 8:59 am
Location: Stavelot / Belgium

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by Eric Pesser »

guro wrote:You may serialize your array before use array_merge. And unserialize in your module after processing cms core.
Mmmh yes that could be a good workaround in this case, but for me, only a workaround. Not a real solution I think.

That should be a better solution if that core function does implement it don't you think?
User avatar
guro
Power Poster
Power Poster
Posts: 985
Joined: Thu Apr 26, 2012 8:38 pm
Location: Ramenskoe

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by guro »

Perhaps. Waiting for response from the core developers.
User avatar
Eric Pesser
Forum Members
Forum Members
Posts: 27
Joined: Mon Oct 13, 2008 8:59 am
Location: Stavelot / Belgium

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by Eric Pesser »

Me too.

Thanks for your contribution, I did not think to serialisation.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by velden »

Just out of curiosity: why don't you use a loop in YOUR code? I'd expect that would be better than changing core code.
User avatar
Eric Pesser
Forum Members
Forum Members
Posts: 27
Joined: Mon Oct 13, 2008 8:59 am
Location: Stavelot / Belgium

Re: Custom module rawurlencode with CreateLink (cause by arr

Post by Eric Pesser »

I should do this in my code, as guro told me, using serialization when a value is an array, use for this my own CreateLink/CreateFrontEndLink function. True.

But for me, passing an array by url is not really specific.

Changing the core would manage the case we have to put en array in the url.

Actually, this case gives an error.

This (w2msSearchRegionId is a select/multiple list) :

Code: Select all

&m6c29bw2msSearchRegionId[]=16399&m6c29bw2msSearchRegionId[]=16394&m6c29bw2msSearchRegionId[]
is what I get after form submit. Actually, CMSMS API don't allow me to make such a standard url. Normal?

So I think Core API must either split values like I did, or serialize array.
Post Reply

Return to “Developers Discussion”