Help with HomepagePresenter

chrystman
Member | 7
+
0
-

Hi everyone, i am just begining my php journey i just came across Nette and i want to create a social community website with it. but now i am a bit confused i want to change my homepagepresenter and the default template but the example i found on nette presenter docs is different with the on my site(web-project) i have replaced my default.latte with my own html code but nothing changed. What i want is a presenter example so i can build mine from it, also i want to know if can .html extension for my templates. Thanks.

Petr Parolek
Member | 455
+
+1
-

Hi, solution is turning on debug mode https://doc.nette.org/…on/bootstrap#…

chrystman
Member | 7
+
0
-

Petr Parolek wrote:

Hi, solution is turning on debug mode https://doc.nette.org/…on/bootstrap#…

Hi Petr, Thanks for the response but i am looking for a presenter example other the default Nette prensenter code. I hope you will understand me.
Also i will like to know if can change my template files from .latte to .html
Thnks.

Last edited by chrystman (2022-04-12 11:30)

Marek Bartoš
Nette Blogger | 1263
+
+2
-

i have replaced my default.latte with my own html code but nothing changed

Does it mean you replaced content of file or just created new one, with different name? Nette uses convention which (based on Presenter class file location and current action of this presenter) locates corresponding Latte template unless you explicitly specify template file yourself.

If you just changed the content of file and you see old content in browser, then you have to enable debug mode (for development) or delete /temp directory (for production server)

also i want to know if can .html extension for my templates

You don't have to. You can write same html to .latte files as you would write in .html files. It just allows you to write PHP via Latte-specific syntax on top of it.

Last edited by Marek Bartoš (2022-04-12 11:43)

chrystman
Member | 7
+
0
-

Marek Bartoš wrote:

i have replaced my default.latte with my own html code but nothing changed

Does it mean you replaced content of file or just created new one, with different name? Nette uses convention which (based on Presenter class file location and current action of this presenter) locates corresponding Latte template unless you explicitly specify template file yourself.

If you just changed the content of file and you see old content in browser, then you have to enable debug mode (for development) or delete /temp directory (for production server)

also i want to know if can .html extension for my templates

You don't have to. You can write same html to .latte files as you would write in .html files. It just allows you to write PHP via Latte-specific syntax on top of it.

I replaced content with my own.
Thanks for the .html explanation.
Also how/where do i change my basepath? from www to plublic?

Marek Bartoš
Nette Blogger | 1263
+
+1
-

Also how/where do i change my basepath? from www to plublic?

In app/Bootstrap.php

$configurator->addStaticParameters([
	'wwwDir' => __DIR__ . '/../public',
]);

And rename www dir to public, that should be it.

chrystman
Member | 7
+
0
-

Marek Bartoš wrote:

Also how/where do i change my basepath? from www to plublic?

In app/Bootstrap.php

$configurator->addStaticParameters([
	'wwwDir' => __DIR__ . '/../public',
]);

And rename www dir to public, that should be it.

Thanks a lot you have really make my day.
But please help me with this

class ProductPresenter extends Nette\Application\UI\Presenter
{
private $repository;

public function __construct(ProductRepository $repository)
{
$this->repository = $repository;
 }

public function renderShow(int $id): void
{
// we obtain data from the model and pass it to the template
$this->template->product = $this->repository->getProduct($id);
 }
}

what do i need to change in this code if i want to use it as my HomepagePresenter? Please and please help me

Pepino
Member | 256
+
+1
-

@chrystman you need edit router or rename presenter.

https://github.com/…rFactory.php

	public static function createRouter(): RouteList
	{
		$router = new RouteList;
		$router->addRoute('<presenter>/<action>[/<id>]', 'Product:default');
		return $router;
	}
chrystman
Member | 7
+
0
-

Pepino wrote:

@chrystman you need edit router or rename presenter.

https://github.com/…rFactory.php

	public static function createRouter(): RouteList
	{
		$router = new RouteList;
		$router->addRoute('<presenter>/<action>[/<id>]', 'Product:default');
		return $router;
	}

Hi thanks, my problem with nette is, looking at my HomepagePresenter which is
<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;

final class HomepagePresenter extends Nette\Application\UI\Presenter
{

}
but if i read the docs about presenters the examples that i see is very different and i am getting confused
that's why i was asking for another prensenter example so that i can see which code renders the template, variables and others.
I hope you understand's me