Selecting a link-button with the DomCrawler - symfony

I'm writing functional tests for my Symfony application.
However, i haven't found a way to click on a link button like this one
<a id="update" title ="Edit this folder" name="update" href="{{ path('folder_edit', { 'id': entity.id }) }}">
<button class="button-strong">
Edit
</button>
</a>
I try to click on it this way :
$link = $crawler->selectLink("Edit")->link();
$client->click($link);
I've tried many others ways but without any success.But when I'm running the tests he keeps throwing this exception :
InvalidArgumentException : The current node list is empty
I've looked if there is a way to just click on a button but it seems to be impossible if there is no form linked to it.
Thank you very much.

Firstly, having a <button> inside a <a> is invalid in HTML 5 and may not work as expected.
Coming to the answer, the reason you are getting that error is due to the difference in whitespace. The crawler will not ignore the whitespace and will thus not find a link that has the text EDIT.
HTML
<a id="update" title ="Edit this folder" name="update" href="#">Edit</a>
TEST
$link = $crawler->selectLink('Edit')->link();
$client->click($link);

Related

Close Button Does Not Display in ui.bootstrap Alert

I am using ui.bootstrap alerts to display messages to users. However, the close button does not display. I'm developing an asp.Net application environment specifically in DNN. That's the only thing I can think of that could be causing the issue.
I have researched the following articles trying to find a fix:
Close button not appearing for Bootstrap alert
https://www.tutorialspoint.com/bootstrap/bootstrap_alerts.htm
I have tried manually providing the code for the button but that doesn't fix the issue.
My code:
<!-- START alerts -->
<div class="col-md-12">
<div class="alert alert-dismissible" uib-alert ng-repeat="alert in $ctrl.alerts track by $index" ng-class="'alert-' + (alert.type || 'warning')" close="$ctrl.closeAlert($index);" dismiss-on-timeout="5000">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">
×
</button>
{{ alert.msg }}
</div>
</div>
<!-- END alerts -->
The message displays and the alert is dismissable and will dismiss itself after 5 seconds as a workaround.
What I can see in the developer console is it's trying to pull a png file that doesn't exist. I can't even tell why it thinks this file would be there as the official bootstrap examples don't show the exact same CSS as I'm seeing in my environment.
// path it's looking for: WEBSITE/Portals/_default/Skins/MyTheme/assets/img/remove-icon-small.png
background-image: url(../img/remove-icon-small.png) !important;
Any thoughts on what I else I could try? Thanks in advance.
Update: adding the missing png file to the location it's looking for it still does not cause the icon to display.

Problems getting Iron Router to work on my project

I'm trying to create a quiz app on Meteor and have had trouble setting up Iron Router forever. I'll try to give a visual:
This is the front page:
Image 1
When a user clicks on the button shown above, I want the first question to show up, whose contents are filled from MongoDB.
Image 2
This is what my router looks like ("question" is the name of the question template, as seen in image 2):
Router.route("/quiz/:_id", {
name: "question",
data: function(){
return Quiz.findOne(this.params._id);}
});
Now, in order for me to get from image 1 to image 2, I have to use a mongo object _id in the html file.
<template name="main">
<div class="jumbotron">
<h2>
Welcome to Simple Meteor Quiz app!
</h2>
<p>
To try it out, simply click "start" below!
</p>
<p>
<a class="btn btn-primary btn-large" href="/quiz/cieLkdzvGZPwrnZYE">Start</a>
</p>
</div>
</template>
When I click "Next Question" on image 2 to go onto the 2nd question, it doesn't work. I don't know how to make this process dynamic.
The way it looks to me right now is that I physically have to create a new route for every single question, which would look really ugly really quickly.
Any way to help implement Iron Router in this scenario? I read Discover Meteor and thought I fully understood how Iron Router works, but the more I try to fix this, the more I get confused.
Edit:
To solve my dilemma, I simple created a helper function which I could place behind the /quiz/ in the main template to lead me to the quiz question, based on a suggestion by Michel Floyd.
So the helper ends up looking like this:
Template.main.helpers({
nextQuestion: function(){
queue = Quiz.find().fetch();
return queue[0]._id;
}
});
Then attached to the URL like this:
<a class="btn btn-primary btn-large" href="/quiz/{{nextQuestion}}">Start</a>
Basically just spit out the first _id of first item in the array by making the collection an array via find().fetch(). Will probably randomize the _id at a later time.
You need a way for each template to know what the next question is. For example you can add a nextQuestionId key to your Quiz object. Then your template can be:
<template name="main">
<div class="jumbotron">
<h2>
Welcome to Simple Meteor Quiz app!
</h2>
<p>
To try it out, simply click "start" below!
</p>
<p>
<a class="btn btn-primary btn-large" href="/quiz/{{nextQuestionId}}">
Start
</a>
</p>
</div>
</template>

Setting javascript function for all <a>

I have a lightbox script that Im using:
<a class="lb-image-link" href="images/image-1.jpg" data-lightbox="lb-set">
<img class="lb-image" src="images/thumb-image-1.jpg" width="150" height="150"/></a>
But for my clients sake to use CMS software I need to make the data-lightbox="lb-set" function work for all <a> tag on the page or to make it work as a class somehow if possible.
The page is HTML, how can I make this work? Im guessing I need to create javascript for this. Any help is greatly appreciated, thank you
One way would be to learn some jquery, if you are not already familiar with it
http://jquery.com/
and then you can easily attach a function to all click events on every a tag on the page with something like:
$("a").click(function(event) {
//your lighbox code goes here ...
});
EDIT
With the lightbox2 script you are using it doesn't look like there is a way to assign it to a group of links on your page based on class or tag type, so the above function is not relevant. At a quick glance, if you stick with that script the only way to have it work on multiple links on the same page is to include a unique data-lightbox="" attribute in each link, eg.
image #1
image #2
image #3
There are other lightbox scripts that allow you to set the lightbox based on tag type or class, for instance http://fancyapps.com/fancybox/ allows you to do the following:
<a class="fancybox" rel="group" href="big_image_1.jpg">image #1</a>
<a class="fancybox" rel="group" href="big_image_2.jpg">image #2</a>
and then use the script
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox();
});
</script>
the above essentially attaches the fancybox lightbox to anything that has a class="fancybox"
Not sure if that helps - there may not be much difference for you having to add a unique data-lightbox="image-3" to each link as apposed to adding a standard class to them :-)
Glen

Drupal: Overriding user-profile.tpl: "print theme('username', $user);" shows the logged in user´s name instead of the profile owner

Well, as the title says, I´m trying to override the whole user profile template in a Drupal 6 installation.
This is what I´ve got so far:
<h1><?php print theme('username', $user); ?> <a class="btn btn-primary btn-mini" href="/user/<?php print $user->uid;?>/edit">edit my account</a> <a class="btn btn-danger btn-mini" href="/user/<?php print $user->uid;?>/profile/perfil">edit my profile node</a> <a class="btn btn-mini" href="/logout"><b>log out</b></a></h1>
<br><?php print $user_profile; ?>
The idea is to take over the profile to show no tabs:
USERNAME [edit account button] [edit nodeprofile button]
[everything else that´s usually inside the user profile]
My problem is that the code above, shows the logged in user username (and the edit buttons) instead of the profile owner´s.
$user_profile; is working ok, because the stuff that shows after the buttons is the profile owner´s.
How should I twist that to act as I want it to?
Thanks!!!
Rosamunda
Just in case someone wonders, I´ve just been able to find the answer and wanted to share it:
<?php echo $account->uid;?>
<?php echo $account->name;?>
As I´ve learn, if you want to show the logged in user, you use USER, when you refer to the accoun´t owner, you simply use ACCOUNT.
Cheers,
Rosamunda

How to WelCome control in Webpart code?

I need to place a webpart on the page. The webpart need to change Welcome control title. I need to change "WelCome UserName" to "UserName".
I tried http://www.wictorwilen.se/Post/Having-fun-with-the-SharePoint-Welcomeascx-control.aspx , But it did not worked in Webpart. If anybody have idea to change this control. Please share with me.
That article is a pretty comprehensive walkthrough of one way to do this - perhaps your focus should be to determine where you have gone wrong in the implementation of it?
An alternative (hacky) method would be to put some javscript into the page using a CEWP or modifying the master page that will search for the welcome string and remove it.
Hint - don't search for "Welcome", search for its container which looks a little like this (some attributes stripped out for clarity
<span title="Open Menu">
<div id="zz7_Menu_t" ...
class="ms-SPLink ms-SpLinkButtonInActive" >
<a accesskey="L" id="zz7_Menu" ... href="#" serverclientid="zz7_Menu"
menutokenvalues="MENUCLIENTID=zz7_Menu,
TEMPLATECLIENTID=zz3_ID_PersonalActionMenu">
Welcome UserName
</a>
</div>
</span>
Some links to get you started
http://www.dlocc.com/articles/style-a-page-using-the-content-editor-web-part-and-css/
http://www.cleverworkarounds.com/2008/02/28/more-sharepoint-branding-customisation-using-javascript-part-2/
http://blog.pathtosharepoint.com/2008/08/10/the-content-editor-web-part/

Resources