problem s odkazem
- crook
- Člen | 13
Dobrý den
Mám problém. Snažím se teď naučit nette a nefunguje mi linkování na
presenter:template
Konrétně: {$presenter->link}
Můžete se na to mrknout?
struktura: app/models
– BaseModel
– MembersModel
– Users
– Novinky
app/presenters
– MembersPresenter
– DefaultPresenter
app/templates/Default
– default
app/templates/Members
– view
app/bootstrap.php
<?php
require_once LIBS_DIR . '/Nette/loader.php';
Debug::enable();
Environment::loadConfig(APP_DIR . '/config.ini');
$loader = new RobotLoader();
$loader->addDirectory(APP_DIR);
$loader->addDirectory(LIBS_DIR);
$loader->register();
$application = Environment::getApplication();
$router = $application->getRouter();
// mod_rewrite detection
if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
$router[] = new Route('index.php', array(
'presenter' => 'Default',
'action' => 'default',
), Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>/<id>', array(
'presenter' => 'Default',
'action' => 'default',
'id' => NULL,
));
} else {
$router[] = new SimpleRouter('Dashboard:default');
}
$application->run();
?>
app/config
[common]
database.driver = mysql
database.lazy = TRUE
database.charset = utf8
service.Nette-Loaders-RobotLoader.run = TRUE
; dalsi nastaveni tvoji aplikace...
[development < common] ; vývojová mašina
database.host = localhost
database.database = vasek-bar
database.username = root
database.password =
set.include_path = "%appDir%/libs;%modelsDir%/;%presentersDir%/"
service.Nette-Security-IAuthenticator = Users
document_root/htaccess
# disable directory listing
Options -Indexes
# mod_rewrite
RewriteEngine On
# RewriteBase /
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
index.php
<?php
// absolute filesystem path to the web root
define('WWW_DIR', dirname(__FILE__));
// absolute filesystem path to the application root
define('APP_DIR', WWW_DIR . '/../app');
// absolute filesystem path to the libraries
define('LIBS_DIR', WWW_DIR . '/../libs');
// load bootstrap file
require APP_DIR . '/bootstrap.php';
?>
@layout
<body>
<div align="center">
<img src="./images/hlavicka.jpg" />
<div style="position:absolute; left:291px; top:347;">
<a href="{$presenter->link('Default:default')}" class="LeftMenu">Home</a>
<a href="{$presenter->link('Members:view')}" class="LeftMenu">Lidé</a> ////nefunguje!!!
</div>
{foreach $flashes as $flash}<div class="flash {$flash->type}">{$flash->message}</div>{/foreach}
<div id="content">
{include $content}
</div>
</div>
</body>
Problém je v tom,že jakmile kliknu na odkaz <a
href=„{$presenter->link(‚Members:view‘)}“
class=„LeftMenu“>Lidé</a>
nefunguje. Odkaz se mi vypise ve tvaru http://localhost/…embers/view/
Chyba asi bude v routu nebo tvaru adresy ale nemuzu to najit Dekuju
za pomoc
- Ondřej Mirtes
- Člen | 1536
Můžeš použít kratší zápis {link Members:view}
a
{link Default:}
.
Co konkrétně znamená „nefunguje“? Co se stane po kliknutí na ten odkaz?
- crook
- Člen | 13
Prominte, trochu jsem se s tim pohral a upravil route, takze se mi ted cesta
ukazuje
dokument_root/members/?action=view coz je doufam zpravna cesta ve zpravnem
tvaru, ale porad Page not found.
Prestavam si vedet rady.
RewriteBase bych nastavil na /vasek-nove/document_root nepomohlo ale diky za kazdou radu.