Welcome Guest, Not a member yet? Register   Sign In
Database driven routes in CodeIgniter
#11

[eluser]neillyons.co[/eluser]
@clooner Not sure if you arrived at this forum topic directly or through my more recent post. There I talk about including a cache file in the routes.php file similar to what your describing. Although the cache file is not created when you access a certain controller but whenever an insert/update/delete operation is performed on the route model.

With your solution I think there might be an issue with lag time. For example, say I have just created an article on my website. It has CodeIgniter's default route of articles/get/1 and an alias of that route like so articles/my-example-article.

I'm assuming your updating your cache file on a cron once a day. So the time between the article being created and the cron being run that route (articles/my-example-article) will produce a 404 error.

Does that make sense?
#12

[eluser]Unknown[/eluser]
Hello,

I am using this piece of code and I want to extend it. But I need now a config variable in the Router_Hook.php.
To do this, I thought I do the same as with the database variables:

So in the hook.php file I added the following:
Code:
require_once BASEPATH."application/config/config.php";
And I thought now I can access all the config variables. But it isn't!

if I do for example:
Code:
echo $config['base_url'];
in the hook.php file. It seems that this variable is empty. if I print the config array I don't see the content. Even not Array( ).

What is going wrong?
(I'm new to CodeIngiter)

Thanks,
Kristof
#13

[eluser]neillyons.co[/eluser]
@Kristof Mariƫn there's a function to access configuration variables stored in the config.php file.
Code:
$base_url = config_item("base_url");

Then if you want to print it out:

Code:
print $base_url;

You can also get the entire config array using:
Code:
$config = get_config();

And print it out like so:

Code:
print $config["base_url"];




Theme © iAndrew 2016 - Forum software by © MyBB