Output a resource table inside of a custom Laravel Nova Tool - laravel

What I'm trying to build:
A custom tool, where, I can have 4 buttons at the top of the page. Then, when a user clicks a button, it will load an index type table, similar to a Nova resource table.
For example: A user could click on the "Widgets" button and it would load a "Widgets" resource table below. Next, the user could click on the "Doodah" button and it would then, instead, load the "Doodah" table below. ... My main question is if there's a way to just harness what's already written in Nova and import it into my custom tool.

The simplest solution is to add a router-link with the resource details inside the navigation.blade.php like this
:to="{
name: 'index',
params: {
resourceName: 'your resource urlKey',
},
}"

Related

Kentico 13 Xperience View Component displaying Page Type field data

If I had a page type called "MySite.TextBox" and it had two fields: "Title" and "Content" what all would be required for me to make a view component that pulls all page types from the site searching from "/" and looking down to have it appear as a list of items in any view, including the layout view, using something like <vc: text-box-list > in a view, such as the _layout
What files would I need to create aside from the TextBoxList view component?
I know I'll need to make a generated code file for the MySite.TextBox page type. But it's where I set up and establish the rules for outputting the list that things get fuzzy.
For instance if I wanted to establish rules like:
var textBoxList = DocumentHelper.GetDocuments("MySite.TextBox").TopN(5).Path("/", PathTypeEnum.Children).OrderByAscending("Title").ToList();
Would that be a part of the view component or something else?
I would just really really love to have an example. I hate that the Dancing Goat and Medio Clinic sites do not have one.
1. Follow the below to Create a widget -
https://docs.xperience.io/developing-websites/page-builder-development/developing-widgets
2. Retrieves pages of multiple page types from the '/' section of the content tree:
var pages = pageRetriever.RetrieveMultiple(multiDocumentQuery => multiDocumentQuery
.Path("/", PathTypeEnum.Children));
Reference:
https://docs.xperience.io/custom-development/working-with-pages-in-the-api#WorkingwithpagesintheAPI-Retrievingpagesonthelivesite
3. Retrieve Common data from multiple page types
var commondata=Pageretriver.RetriveMultiple(multiDocumentQuery=> multiDocumentQuery
.Types("PageType1","PageType2)
.WithCoupledColumns())
.Select(page=> new <desiredobject name>
{
fieldName=page.GetString("fieldName")
});
Reference
https://docs.xperience.io/custom-development/working-with-pages-in-the-api/reference-documentquery-methods

View Composer for sidebar in Laravel

using a view composer for the first time in Laravel. i have a sidebar that is included in every step of a submission form process a user goes through. i want the sidebar to have link that apply to the proper submission (i.e. if this is submission number 5, the links in the sidebar should all go to the edit function for submission 5.
i have the following code in my web.php:
View::composer('layouts.planbuilder', function($view){
$plansubmissions = PlanSubmission::find(3);
$view->with('plansubmissions', $plansubmissions) ;
}) ;
i am able to access the $plansubmissions variable, but of course this only applies to submission 3, which i hard coded in. is it possible to get the logic from another controller? i can't just get the user id with Auth because a user can have many submissions
View Composers also have access to the variables that were passed to the view itself, so if you are passing the submission to your view from the controller like so
return view('submissions.show', compact('submission');
Then in your composer you can assign it to $plansubmissions
$plansubmissions = $view->getData()['submission'];

Joomla content edit call stack and URL routing

I am using Joomla 3.x CMS. I have SEO enabled. I am also routing the URL so that article IDs, category and category IDs are hidden. Hence a typical article with an alias of my-alias will have the URL: http://localhost/my-alias. I am doing this routing in a system plugin in method onAfterInitialise(). All aliases in the system are ensured to be unique. Now when an article is being viewed, anyone with access will see an edit URL as follows: http://localhost/my-alias?task=article.edit&return=someValidToken. This too is routed properly to the actual article to be edited.
When viewing an article, the user/browser does not see the article ID (as desired). When editing, the user/browser sees the article ID (not what I want). That is, when user clicks the edit link, browser loads the edit form and user sees the following URL: http://localhost/edit-article?view=form&layout=edit&a_id=1002&return=someValidToken, where 1002 is the article ID.
Following is a code snippet from onAfterInitialise():
if (isset($query['task']) && $query['task']=='article.edit') {
// TODO Hide this change from the user/browser
JFactory::getApplication()->input->set('view', 'form');
JFactory::getApplication()->input->set('layout', 'edit');
JFactory::getApplication()->input->set('a_id', $articleId);
}
else {
JFactory::getApplication()->input->set('option', 'com_content');
JFactory::getApplication()->input->set('view', 'article');
JFactory::getApplication()->input->set('id', $articleId);
}
JFactory::getApplication()->input->set('Itemid', 111); // map to dummy item in hidden menu with alias edit-article
I would like to know how to solve this. An understanding of the call flow through the Joomla framework will help.

How to pass value to layout without passing value from all functions in Laravel?

In my project I am using a layout file and other view files. In my layout, there is a place to display users data. But I using this layout for different pages, so when I uses this layout for each pages, I need to pass user details from corresponding functions to view page. Is there any other short cut to pass user data only once, to layout directly??
Can anyone please reply??
Use Laravel View Composers
Official documentation
Here is an example :
'layout' is your view
View::composer('layout', function($view)
{
$view->with('count', User::count());
});
Put this into your "/app/start/global.php" file

Joomla modules to only displayed to specific usersgroup

I need to able to restrict menu modules to their user group. I have two user group called "contractor and supplier" I have separate menu module for each and only be seen if they are they user group.
But when I login for either I can see the other user menu, visit http://new.oljanafm.com.au And login as a supplier on both login forms:
username: telstra
pw: 1234
How do I make it so each menu can only be seen when they login.
Thanks,
Nep
Menu's are displayed by modules, simply set the menu to the group you want.
In the module that displays the menu set the Access menu to the "Contractor" or "Supplier" group as required.
e.g. in the Joomla 3 Manager you can see the Modules button on the right end of each Menu row.
If you click on the Modules button you will be shown a summary of where it's displayed (template position) and the viewing access group that can see it, as shown below:
If you click on the module entry you can edit the module directly and set the access, like this:
Try this,
In your module , you can create User Groups as a Module Params.
So using this option once the module is installed for one menu item choose required user groups. Then for the second menu item create New module from Module manager ->Tool bar menu.
choose the other user groups from module param.
Assign each module correctly with menu's. Simply Done!
You can create usergroups in module param using the following code in your module XML
<field name="guest_usergroup" type="usergroup"
label="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL"
description="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC"
multiple="true" />
For more about usergroups, and more about module params.
Hope it make sense..
I'd suggest you to use a 3rd party solution called Metamodpro
Once you install that, here are some recipes that you could use:
if (MM_USER_REGISTERED ) return 46; //a plain registered user, no additional privileges
if ( MM_USER_AUTHOR ) return 47; //show a notice for "Author" users
if ( MM_USER_EDITOR ) return 48; //show a notice for "Editor" users
if ( MM_LOGGED_IN && MM_NOT_USER_AUTHOR ) return 53; //show a notice to anyone logged in who is not in the "Author" group
if ( $user->usertype == "My Special Group Name" ) return 54; //if you are using any Joomla extensions that allow you to create your own user groups

Resources