Welcome Guest, Not a member yet? Register   Sign In
Controller parameters change depending of URL
#1

[eluser]Alface[/eluser]
I'm making an ajax pagination for my news page.
all notices have (year, month, state)

I create the ajax part as well, but I notice.. the url stays
localhost/news
all the time.. and for seo and best user navegation and SEO I want to populate ajax aplication with url values too (not just the form)

to get directly access like this:
localhost/year/month/state/page

Ex: localhost/2010/04/01/2

late I replace 04 on the url to April.. just for keep simple

My problem:

Code:
<?php
class Site extends Controller {

    function Site(){
        parent::Controller();

    function news($year = NULL, $month = NULL, $state, $page = NULL){
        }
}

The problem is year, month and state is optional..
and if I do not set year, month wil turn to year.
and if I do not set month, state wil turn to month.


undertand?

If I got keys (like $_GET) the problem was solved. But the is another way?

Thanks for everthing Smile
#2

[eluser]Mareshal[/eluser]
Make it array

function news($params = array())

and you call this function like this

news(array('month' => '4')); or everything you need. At least this is what I use.
#3

[eluser]Alface[/eluser]
[quote author="Mareshal" date="1272723821"]Make it array

function news($params = array())

and you call this function like this

news(array('month' => '4')); or everything you need. At least this is what I use.[/quote]

But I want to recive the value from the URL.
#4

[eluser]Mareshal[/eluser]
And I want a Pizza now...(I'll get it later)

If I were you, I would use the URL like this: /site/news/year/2010/month/02/state/1

and using $this->uri->uri_to_assoc(n) : find it here: http://ellislab.com/codeigniter/user-gui...s/uri.html

make the url like this

[array]
(
'year' => '2010'
'month' => '02'
'state' => '1'
)

and problem solved...at least for me.

And be sure you read this: http://www.phparch.com/2010/04/29/less-c...ys-better/




Theme © iAndrew 2016 - Forum software by © MyBB