thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.77k stars 2.67k forks source link

Url for pages infrontend #763

Closed miladaws closed 7 years ago

miladaws commented 7 years ago

Hi

I created a page in admin panel. I want to know what the url is. Do I have to create controller for this issue or there is a way to show this page in frontend.

Thank you. :)

anderfernandes commented 7 years ago

I'm sort of new to Voyager, but in my projects, I used a controller to get the data from the model and send it to my view. Works like a charm, even with the tables created in admin.

You could also use your favorite javascript library (React, Vue, Angular) to get data from an API you create. In Laravel 5.3, there's an API route file. Return the model you want in the Route::get method and boom! It works.

miladaws commented 7 years ago

Hi

I know about controller and view . There are a menu named page in voyager admin panel ( your_website_url/admin/pages/create ) I meant this type of page . or for example posts .

My question was about this type of post or page.Not a simple page :)

I created a page or a post but I cannot show it on the frontend.

anderfernandes commented 7 years ago

You want to display a custom created menu on your frontend? I'm a little confused. If that's what you want, the documentation explains it really well here: https://the-control-group.github.io/voyager/docs/v0.10/#core-concepts-menus

miladaws commented 7 years ago

Hi

I dont want to load custom created menu on the frontend. I want to load post or page on the frontend. There are two menus on the sidebar. ( Post and Pages :: look at the attach please ). I created post and page and want to load them on the frontend but I dont know what the url is.

My question is related to them. Is there any solution to get the url of post or page? For example I create a page named about us. How can I show it on the frontend?

voyager-roles

anderfernandes commented 7 years ago

In my project I did this with a controller. You can, let's say, create a view called about.blade.php create a PageController. Inside of this controller you can create an about function that returns the contents of your about us page from the page model. This controller function would look something like:

// Show About Page
    public function about()
    {
      // Get content of the about page from the model, feed Page::find with page id
      $about = Page::find(1);
     // Return view with the data
      return view ('about')->with('about', $about);
    }

Then on your view you can print the content of the page using blade. For example, to print the page body you can do something like:

{!! $about->body !!}

I'm still a beginner in the PHP/Laravel/Voyager world, but that's how I would do it.

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.