Mal Blackshaw Wed Apr 18 11:16:06 -0400 2012

Subject: Slim Framework & Twig & php.activerecord query other than id

Afternoon,

I'm a bit stuck with a query, and still trying to wrap my head round slimframework & active record I have adatabase with a navigation table and content table, I can get the navigation to pull through using the following:
slim FW code:
$app->get('/', function () use ($app) {
$nav['navigations'] = Navigation::find('all', array('conditions' => array('status = ?', '1')));
$app->render('navigation/index.html', $nav);
})->name('page');
Twig: {% block navigation %}
<ul> {% for navigation in navigations %}
<li><a href="{{ navigation.safeurl }}">{{ navigation.menuname }}</a></li> {% endfor %}
</ul> {% endblock %}

this pulls the navigation data through no problems, giving me seo friendly URLS but I can't seem to ref the content data to pull using anything other than ID how would i query the following to pull url from the page content table so it gives me seo friendly urls instead of http://www.sitename.com/1 or http://www.sitename.com/2 and so on....:
$app->get('/:url', function ($url) use ($app) {
$data['page'] = Page::find_by_url($url);
$nav['navigations'] = Navigation::find('all', array('conditions' => array('status = ?', '1')));
$app->render('navigation/index.html', $nav);
$app->render('page/page.html', $data);
})->name('spage');

Cheers

Mal


Mal Blackshaw Fri Apr 20 05:14:25 -0400 2012

resolved this...

Kanen Nova Sun May 20 20:17:34 -0400 2012

Mal Blackshaw wrote:

resolved this...

Hi Mal,

I've been scavenging the web for a solution like this. Please do share your code.

Thanks!

(1-2/2)