luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
811 stars 207 forks source link

Wrong url on news module #1251

Closed rodzadra closed 6 years ago

rodzadra commented 7 years ago

What steps will reproduce the problem?

Install, configure and create articles on news modules: https://luya.io/guide/module/luyadev---luya-module-news.

Integrate the module link showed in "#3 Module integration via Block in LUYA CMS" video: https://www.youtube.com/watch?v=nHxV-ke8CVw.

What is the expected result?

Once integrated, the link to the detail (using $ item-> detailUrl) is not being directed to the correct location. I believe it should direct to: http:///www.site.com/**news**/ID/SLUG but it is directing to http://www.site.com/ID/SLUG.

Also, by going directly to http://www.site.com/**news**, the tag "link[]()" is not rendering the HTML element "<a></a>". Not even the use of $ item->detailUrl is rendering correctly.

What do you get instead? (A Screenshot can help us a lot!)

luya_news_module

luya_news_module1

Additional infos

Q A
LUYA Version ^1.0@dev
PHP Version 5.6.12
Platform Apache 2.4.16/MariaDB 5.5.43
Operating system GNU/Linux Slackware 14.0
nadar commented 7 years ago

I guess this is because you have setup the module on the default page (homepage) which has no slug. Could you please make new site: articles and integrate the module block there? just for testing purpose.

rodzadra commented 7 years ago

@nadar, I did the integration of the module, both on the main page (default page) and on a secondary page and the error occurs in both.

nadar commented 7 years ago

Hmm ok, i will try to recreate your problem. Here some additional infos about module block and create a page using a module.

There are two behaviors of how to implement a module:

  1. You can use the module block, this will just render the controller based logic of the module and return the html where the block currently is. So its not thought to have links and further actions/controllers. Its more really to just render something dynamic.

  2. You can create a new page using the module type, then the cms will give the full control to the module, so you can change title tags, run further actions and controllers, thought for news, estore, etc.

So in your case maybe it would make more sense to integrate the news system as a module page (2.) in then just display the latest news trough a block you can drag into the frontpage.

rodzadra commented 7 years ago

But when I create a "module page" how can I integrate it to another page? Or is there no way?

rodzadra commented 7 years ago

Another question, if a page is created as a module, is it accessible through the "module" block?

nadar commented 7 years ago

I am not sure what you mean by "accessible by the module block"?

rodzadra commented 7 years ago

Sorry, what i need is to know how to use an page created like a module inside (or within) the frontpage. :)

nadar commented 7 years ago

you can use a module via the module block or create a page "type module" for the frontpage. But if you just want to tease data on the frontpage but having the module and itrs full control on a subpage, you maybe better just create a block for the frontpage which then redirect to the module detail (like news detail). If we are not talking about the same, make me an example what you like to do, i am sure we can find a good solution ;-)

rodzadra commented 7 years ago

@nadar,

In my case, I would like to use the news module on the main page.

In my project, I have only two categories. I created a view with two columns - the one on the left with generic news and the one on the right with institutional news.

What I hoped was that it would be possible simply to insert the news module into the frontend page and it would work magically. :)

In insert parts the news module works. However, when I use the detailUrl method, to go to the rest of the news, the URL was not generated correctly. If that were resolved, in my specific case, it would be great! :)

rodzadra commented 7 years ago

@nadar,

If i hardcode the "modules/news/src/models/Article.php" file, to:

@@ -135,7 +135,7 @@ class Article extends NgRestModel
      */
     public function getDetailUrl()
     {
-        return Url::toRoute(['/news/default/detail', 'id' => $this->id, 'title' => Inflector::slug($this->title)]);
+        return Url::base().'/news/'.$this->id.'/'.Inflector::slug($this->title);
     }

     /**

This will work for me. But i don't know if this is the best solution.

TerraSkye commented 7 years ago

@rodzadra that is no fix, since u hardcode the url instead of letting the url manager do the work.

masihfathi commented 6 years ago

maybe this is because of url rule

nadar commented 6 years ago

@rodzadra this is a very old issue, but i assume i have "fixed" the bug. Now on the homepage it will generate the "original" url path to the module like mymodule/controller/action but its currently not possible while parsing the request, as we then don't know the url was requested on the homepage.

Maybe, if you still have your setup somewhere ;-) you could try to install the latest dev-master and let me know if its working now out of the box.

masihfathi commented 6 years ago

hi @nadar and thanks, i check it, the problem solved in my project, now in the home page i have used news block and urls are correct.

nadar commented 6 years ago

Perfect! Thanks for the response @masihfathi