Yii2 Url Html format - html

Quick Question:
i use following code in my View Script to generate a link
<?=HTML::a("(".$player['player']->steam_id_32.")",['steam/','steamid'=>$player['player']->steam_id_32])?>
This is going to return following link
/web/steam/STEAM_0%3A0%3A96553432
how can i have it return
/web/steam/STEAM_0:0:96553432
i tried some thing but could not figure it out thank you

This behavior is by design. You can't really change this behavior, but you could use a workaround.
The code below first creates the url and then decodes it. Then create the link (<a>) with the previous created url.
$url = urldecode(Url::toRoute(['steam/', 'steamid' => 'aa:bb:cc']));
echo Html::a('title', $url);

Related

Link that forwards the URL's parameters

There is a main Sales Page: site.com/sales-page
That page receives visitors from different traffic sources, and they are mentioned on its URL parameters, such as: site.com/sales-page?utm_source=fbads&utm_campaign=banner
That Sales Page has a link pointing to BUY NOW
How do I pass all URL parameters from the current window, such as "?utm_source=fbads&utm_campaign=banner" automatically to the next page via the BUY NOW button?
I need this so the Checkout page will know where the traffic came from, based on that forwarded parameter.
PS: I want to pass all parameters available in the URL, not just pre-defined ones.
PPS: Solution must work on most browsers and on static pages, better to not use cookies/php.
Thanks a lot.
There is no way to achieve this using HTML. You have to use a programming language.
For example:
<?php
$url = "http://example.com/foo/?" . $_SERVER['QUERY_STRING'];
?>
link
If you don't want to use PHP, then other programming languages are available.
There is no way to do it with just html. Best solution is serverside code. Fallback is to use JavaScript, but this will not work if JavaScript is disabled. You can read the search from the url and add it to your link.
<a id="buyNow" href="http://www.example.com">Buy</a>
<script>
(function () {
var lnk = document.getElementById("buyNow");
lnk.href = lnk.href + window.location.search;
}())
</script>
This assumes there is no querystring already on the link. If there is, you need to replace the ? in the search with a &

Direct link to YouTube comments

Is there a way to link directly to the comments section of a YouTube page?
I know that this can be done using anchors and div ids, but this has been unsuccessful when I applied it to a YouTube URL, because YouTube strips the forward slash on page load.
For example, https://www.youtube.com/watch?v=eRsGyueVLvQ/#comments becomes ?v=eRsGyueVLvQ#comments
Is this possible, or should this be chalked up to a feature request?
You can make a certain comment appear at the top of the comment section by clicking on how long ago it was posted (e.g. 2 years ago).
This will take you to the same YouTube video, but with a URL which looks something like this: https://www.youtube.com/watch?v=VIDEO_ID&lc=COMMENT_ID (just like in Mr.Rebot's answer).
You can also do this for replies as well.
If you will use the CommentThreads:list:
Returns a list of comment threads that match the API request parameters.
Code Snippets:
// Sample PHP code for commentThreads.list
function commentThreadsListByVideoId($service, $part, $params) {
$params = array_filter($params);
$response = $service->commentThreads->listCommentThreads(
$part,
$params
);
print_r($response);
}
commentThreadsListByVideoId($service,
'snippet,replies',
array('videoId' => 'kmXXXLBL3Nk'));
Then you can create a link with with the URL:
https://www.youtube.com/watch?v=VIDEO_ID&lc=COMMENT_ID
This link is not generated in the API so you should create a function for this.

Convert codeigniter code to html

I have placed a codeigniter code and i want that code in html.Pls help me to do this.
<? echo anchor('login/signup', 'Create Account');?>
Not sure why you want that code (which generates an anchor when the HTML page is rendered - look at your browser page source)
But what that CI URL helper translates to is:
Create Account
I can only assume you maybe want to add attributes to it and don't know how?
For example, you could add an ID and/or class like so:
<? echo anchor('login/signup', 'Create Account', 'id="some-id" class="some-class"');?>
Just make sure you're loading that 'helper' in your controller, or set it to autoload in the config/autoload.php file (which makes the most sense for this type of helper, as it'll likely be used site wide).
For more info on the CI URL Helper, visit here:
http://ellislab.com/codeigniter%20/user-guide/helpers/url_helper.html

Unable to find web elements, using selenium::remote::driver perl bindings, whenever base URI changes from default website url

I am writing test scripts for a website using selenium webdriver's perl bindings. The problem I am facing is mentioned below:
I am not able to find some of the web elements (tried every approach: xpath, id, css, etc.) which exist on the web page, although I can click on them as a user.
After debugging through firebug I found that there is a property called base URI. And this has a different value from one web element to another. So whenever BASE URI = URL, I am able find elements and work on them.
But if BASE URI IS NOT EQUAL TO URL I am unable to find web elements.
Here is a sample code for successfull case:
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::More "no_plan";
use Test::Exception;
use TAP::Harness;
use Data::Dumper;
use Selenium::Remote::Driver;
use Selenium::Remote::WDKeys;
my $url = 'https://www.xyz.com/';
my $sel = new Selenium::Remote::Driver('browser_name' => 'firefox',
'platform' => 'VISTA');
ok(defined $sel, 'Object loaded fine...');
ok($sel->isa('Selenium::Remote::Driver'), '...and of right type');
$sel->get("$url");
is ($sel->get_title(), 'xyz','Got the right title');
my $elem = $sel->find_element('html/body/div[1]/div/header/div[1]/div/center/div/ul/li[1]/a');
ok(defined $elem, 'packageLink web element defined');
$elem->click();
In this case the DOM structure shows that base uri is the same as url.
Now for unsuccessful the case, the DOM shows the base URI as https://www.xyz.com/epg.php
In the above mentioned code, if I use the $sel->navigate(https://www.xyz.com/epg.php) command just before the find element command then the script will be able to find the elements. But it will be just a static page click and will give no response.
I am a first time user of HTML related tasks. I would appreciate any kind of help.
Thanks,
Abhishek

HTML_purifier stripping display:none css from images, even with CSS.AllowTricky set to True?

That title is probably a bit confusing so let me elaborate.
I'm using HTML_purifier to clean up user input, although in this case the only user who will be using it will be myself (its in password protected folders). A long story short I would like to be able to add in image tag code to a web form, then on the page that it sends too use the code to display said image.
However i need the image tag to have css attributes added to it, one of which is
display:block
Anyway by default HTML_purifier removes this, detailed here because of the CSS.allowTricky option. As i understand it if you set the CSS.allowTricky option to True, then it should allow
display:block
However after doing this its still removing it, just wondering if anybody has done this before as i can't find much documentation about it on the web? Its not generating any errors in syslog, so im assuming that its the correct implementation but isn't working as expected.
My code at the moment.
include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);
* UPDATE **
The code should pass the config object (which the code already set) to the html purifier object. Putting it together it should look something like this.
include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);
$purifier = new HTMLPurifier($config);
Duplicate of http://htmlpurifier.org/phorum/read.php?3,6724 (solution was passing the config object to the HTML Purifier object so that the config actually got applied.)