In Yii2, I have manually added a new page backend/views/site/new.php.
Then I have given a link in the page backend/views/site/index.php:
New
When I click the link it shows:
Not Found (#404)
What's the issue here?
Create action in SiteController.php like below
public function actionNew()
{
return $this->render('new');
}
And also create new.php file in views/site/new.php
Add New page link in the page backend/views/site/index.php like
<?= Html::a('New', ['new']) ?>
Related
So here is the explanation of the problem I am facing. It might look very similar other already asked questions, but none of them answered my problem.
I want to open an angular template reference in a new browser window (with all the styles) and use that window to print the contents using system print dialog.
By template reference I mean a whole component or may be just a fraction of template of given component.
Please note that I do not want to do it by below methods:
Opening a new route in a new browser window. (Why? this will cause all other things like common toolbar or help open up with the component. Also a new route will be required which is undesired.)
Opening the content in a closable modal.
Ok, This is how I did it using ComponentFactoryResolver and Injector. Just inject these two dependencies in your component which wants to open other component (ReportComponent in this case) in new browser window.
The constructor looks something like this in snippet below.
constructor(
private resolver: ComponentFactoryResolver,
private injector: Injector
) {}
.
.
.
This method opens up the component in new browser window.
public openPrintableReport(): void {
// resolve and instantiate the component which you want to open in new window.
const componentFactory = this.resolver.resolveComponentFactory(ReportComponent);
let component = componentFactory.create(this.injector);
component.changeDetectorRef.detectChanges();
// define external window
this.externalWindow = window.open('', '', 'width=1000,height=1000,left=150,top=200');
// copy all the styles to external window.
document.querySelectorAll('style').forEach(htmlElement => {
this.externalWindow.document.head.appendChild(htmlElement.cloneNode(true));
});
this.externalWindow.document.title = 'Printer Friendly Report';
// attach the component to external window
this.externalWindow.document.body.appendChild(component.location.nativeElement);
}
I am trying to add a few custom fields to the edit.php page ( Post List Page )
It is a few settings like asking the user whether post must be displayed in 2,3 or 4 columns w, and I specifically want it on this page.
I have found a way to add content with a function to the right place without editing the wp-admin/edit.php or wp-admin/custom-header.php
add_action( 'load-edit.php', function(){
$screen = get_current_screen();
if( 'edit-post' === $screen->id )
{
add_action( 'all_admin_notices', function(){
echo '<h2> === Add ACF Fields here === </h2>';
});
});
i am also halfway in adding a location rule in ACF:
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Post']['post_edit_screen'] = 'Post Edit Screen';
return $choices;
}
But how do now create a location rule to show my ACF fields here?
Thank you
I spent hours trying to extend the ACF_Location class without success.
The ACF Extended WordPress plugin provides the desired functionality.
You can find the GitHub repo here.
I believe this is the class that extends the ACF location functionality we both needed. #see acfe_location_post_type_archive class here
I'm working with the Backpack crud 3.2. in Laravel 5.4.
What I need is to add a new custom button inside the list.blade.php near to the Edit and Delete button. And to link another view to the new button.
I had gone through the lines inside the list.blade.php.
I know there are blade files for each buttons,fields and views. But even I couldn't find how these Edit and Delete button were added?
Could anyone help with an idea?
In CURD controller, you can create button here :
public function setup()
{
..............
// ------ CRUD BUTTONS
// possible positions: 'beginning' and 'end'; defaults to 'beginning'
for the 'line' stack, 'end' for the others;
// $this->crud->addButton($stack, $name, $type, $content, $position);
// add a button; possible types are: view, model_function
..............
}
You can see more : https://laravel-backpack.readme.io/v3.0/docs/crud-buttons
I'm working on a project (quite new to this topic) where users can add multiple addresses for one company.
Now I would like to add a partial view to my side (by click on an action link) to have a possibility to enter multiple phone numbers for each of these addresses.
The empty sub partial (for phone and..) should be placed directly after the address where the action link was clicked (inherent div element is placed there)
For example I have two addesses for company xyz I render two actionlinks and for each an pending div element.
How can I tell my ajax action link to update only the coresponding div within a for loop? I mean, if the first link is clicked the partial view should be rendert at the first div elements position and so on. I have an addressId available to add it to the link and the id of the div.
The partial is returned correct by the controller (checked with Fiddler), but it will not be rendert on the page.
If I remove the reference to my "AddressId" in ActionLink's "UpdateTargetId" and in the placeholder div - everything works fine.
If I check webside source code I have the same "names" (ComRow+1) in targetId and div id - see:
... data-ajax="true" data-ajax-mode="after" data-ajax-update="#ComRow+1" href="/companyDetails/GetCommunicationEditor/1">Add a new Phone no./Email for this Address...
and:
</div>
<div id="ComRow+1">
</div>
I found this:
dynamic update target id in Ajax.ActionLink
but it doesn't work in my case (maybe I'm in a for Loop?)
and this:
How to add a Model Primary Key which is INT, to an ActionLink LinkText
but the ".ToString()" does'nt solve the problem
What am I doing wrong? Many thank's in advance
This is the code that generates the loop:
<div>
#for (int i = 0; i < Model.EditorAddresses.Count(); i++)
{
#Html.EditorFor(m => m.EditorAddresses[i])
//Start - render link to add template for the new address
<div>
#Ajax.ActionLink("Add a new Phone no./Email for this Address...",
"GetCommunicationEditor", new { #id = Model.EditorAddresses.ElementAt(i).AddressId },
new AjaxOptions
{
InsertionMode = InsertionMode.InsertAfter,
UpdateTargetId = "ComRow+" + Model.EditorAddresses.ElementAt(i).AddressId.ToString(),
});
</div>
//End - render link to add template for the new address
<div id="ComRow+#Model.EditorAddresses.FirstOrDefault().AddressId.ToString()">
</div>
//<div id="ComRow+<%=Model.EditorAddresses.ElementAt(i).AddressId%>"></div>
...
}
Solved the problem by myself! I removed the string element "ComRow".
I modified the Ajax Actionlink:
UpdateTargetId = Model.EditorAddresses.ElementAt(i).AddressId.ToString(),
The result is: data-ajax-update="#1" (in "view source code" for website)
And I also changed the code of the "div id" to:
id="#Model.EditorAddresses.ElementAt(i).AddressId.ToString()"
With the result:
id="1" if I look at the website source code
P.S. There was also a mistake in the posted code for the div element "...FirstOrDefault().." was wrong. The right way is to use "...ElementAt(i)..".
I think the problem was, that the div id does not accept a "+"
Maybe this helps somebody
I want to route from one page to another page.
Candidatesvas- controller
Here I have code,
[Authorize, HttpPost,HandleErrorWithAjaxFilter]
public ActionResult Details(FormCollection collection)
{
Order order = _repository.GetOrder(LoggedInOrder.Id);
order.CreateDate = DateTime.Now;
order.Amount = 360;
order.Validity = 60;
_repository.Save();
}
when I click Index page,"any link", it saves in db and go to next details page.
Index.aspx:
<%:Html.actionlink("Details","Details","Candidatesvas")%>
like that...
Global.ascx:
routes.MapRouteLowercase(
"SaveVas",
"details/candidatesvas",
new { controller = "Candidatesvas", action = "Details" }
);
But when i click link, it shows "resource cannot be found". i changed many way. please help me. i can't find out the issue?
Your controller action is decorated with the [HttPost] attribute which means that this action is only accessible with the POST verb. Then you have shown some link on your page:
<%:Html.ActionLink("Details","Details","Candidatesvas")%>
But as you know a link sends GET request. If you want to be able to invoke this action you should either remove the [HttpPost] attribute from it or use an HTML <form> instead of a link.
try this
<%:Html.actionlink("Details","Details","Candidatesvas",null,null)%>
You can't use Html.actionlink for post method.
go for jquery
Or call form submit on click function.