Welcome Guest, Not a member yet? Register   Sign In
Navigation Path Problem
#1

[eluser]o_Ojack[/eluser]
hey guys,

im building a test result management application and i need to implement a navigation path in my header similiar to the one use in the forum:
CodeIgniter>Forum Home>CodeIgniter Development Forums>Code and Application Development.

I have only 1 controller class, 1 view for each function in the controller class and all the views use the same header file. What is the easiest way to implent that?
#2

[eluser]zdknudsen[/eluser]
Does that mean you only have two levels of navigation? Effectively having a navigation path like "Controller > Method"?
#3

[eluser]o_Ojack[/eluser]
Hi Zacharias,

I have more than two levels of navigation and there are 3 possible ways of navagation:

index() -> builds() -> build_testruns() -> testrun() -> test()
index() -> testruns() -> testrun_builds() -> testrun() -> test()
index() -> products() -> testrun() -> test()

The problem is all the methods are inside the same controller class, so instead of having hierachy url like http://url/controller/method/method/method, i have http://url/controller/method. That's why I am struggling.
#4

[eluser]sparkling tux[/eluser]
I see the possible solution in storing these paths, or, say info about parent sections in the db, for example. But I'm not sure if it's convenient.
#5

[eluser]o_Ojack[/eluser]
[quote author="sparkling tux" date="1189630519"]I see the possible solution in storing these paths, or, say info about parent sections in the db, for example. But I'm not sure if it's convenient.[/quote]

but the thing is all these information are dynamically generated, it really depends on what's in the database, like the available products, builds and testruns. So I don't think I would be able to store these paths into the database.
#6

[eluser]zdknudsen[/eluser]
Well, unless there are some kind of systematic navigation hierachy you're probably best off using arrays (that's what I do). Like this in each controller:

Code:
$data['crumbs'][] = array('url/to/crumb', 'name');
$data['crumbs'][] = array('url/to/another/crumb', 'name');
$data['crumbs'][] = 'Final crumb'

Then displaying them all like this:
Code:
foreach($crumbs as $crumb){
echo (is_array($crumb) ? '<a href="' . $crumb[0] . '">' . $crumb[1] . '</a>' : $crumb);
}
#7

[eluser]o_Ojack[/eluser]
does it mean i have to define the full navigation hierachy path to the particular controller in each controller? say if a controller is at level 4, then i have to add an array of 3 elements in it?

what if i have something like product:codeigniter -> build: 2007-09-12 -> testrun: x -> test: y
if im now in the test controller, i know i definitely came from product->build->testrun, but how do i know which product, build and testrun i came from, since the information is dynamically generated?
#8

[eluser]zdknudsen[/eluser]
Sorry, I thought you said you had only one controller. Could you explain how your application works?
#9

[eluser]o_Ojack[/eluser]
It's basically structured like this:

class BTRMS extends Controller {

function __construct()
{
}

function index()
{
$this->load->view('product_view',$data);
}

function product()
{
$this->load->view('testruns',$data);
}

function builds()
{
$this->load->view('builds_view',$data);
}

function build_testruns()
{
$this->load->view('testruns',$data);
}

function testruns()
{

$this->load->view('testruns_view',$data);
}

function testrun_builds()
{
$this->load->view('testruns',$data);
}



}
so bascially this is the flow of the application:
- the index class is loaded and calls the product_view to display all distinct products, number of builds in each product, and number of testruns in each product
- the user now have two options, 1 is to see available builds for that product, or available testruns for that product. the former one calls the builds() controller from the product_view, and the latter one calls the tesetruns() controller form the product_view and the product view also passes the select product to the corresponding controller
- builds calls the testruns() calls the builds_view which shows all the builds and number of testruns in each, when user selects a build, the view will then call the build_testruns() method in the controller and pass the product and view to it
- testruns calls the builds() calls the testruns_view which shows all the testruns and number of builds in each, when user selects a testrun, the view will then call the testrun_builds() method in the controller and pass the product, and build to it
-both of the builds_testrun and testrun_builds method calls the testruns_view that shows all the testruns for select product, testrun, and build

sorry if it seems very confusing, let me know if you have you have any questions, i can send you the code if that's easier
#10

[eluser]zdknudsen[/eluser]
If I understand you right, this is how I'd do it:

Code:
class BTRMS extends Controller {

function __construct()
{
$data['crumbs'] = array('url/to/home', 'Home');
$data['crumbs'] = array('url/to/products', 'Products');
$this->load->vars($data);
}

function index()
{
$this->load->view(’product_view’,$data);
}

function product()
{
$data['crumbs'] = array('url/to/product', $productname);
$this->load->view(’testruns’,$data);
}

function builds()
{
$data['crumbs'] = array('url/to/product', $productname);
$data['crumbs'] = array('url/to/build', 'product build');
$this->load->view(’builds_view’,$data);
}

function build_testruns()
{
$this->load->view(’testruns’,$data);
}

function testruns()
{
$data['crumbs'] = array('url/to/product', $productname);
$data['crumbs'] = array('url/to/testrun', 'product testrun');
$this->load->view(’testruns_view’,$data);
}

function testrun_builds()
{
$this->load->view(’testruns’,$data);
}



}
I'm probably completely wrong. You lost me around the testrun_builds() part.. :-)




Theme © iAndrew 2016 - Forum software by © MyBB