I have tried to do url_title().
but how to customize this function?
ok guys... i found the solution....
i customize the url title in url_helper..with use
$str = preg_replace('/[^A-Za-z0-9-]+/', '-', $str);
and its work
Related
Is there a way to do a web scraping without define the HTML tags?
I have my code:
$crawler = $client->request('GET', 'https://www.cnnchile.com/opinion/');
$result = $crawler->filter('.inner-item__content > h2')->each(function ($node) {
return $node->text();
});
but how you can see I alaways define the HTML tag where it's the content, it's there a way to get in general the data? I mean without define that
Thanks
You want just the page content? Then use body as the filter tag.
In laravel 8 app I select active menu item with
<a class="nav-main-link {{ request()->is('admin/compilations') ? ' active_nav_menu' : '' }}"
and it works ok for link like :
http://127.0.0.1:8000/admin/compilations
But it does not work for link like :
http://127.0.0.1:8000/admin/compilations/2/edit
How can be fixed ?
Thanks in advance!
I think the cleanest solution for this is to gives your route names instead of hard-checking URL patterns (https://laravel.com/docs/8.x/routing#named-routes) and utilize one of the following methods:
$route = Route::current(); // Illuminate\Routing\Route
$name = Route::currentRouteName(); // string
$action = Route::currentRouteAction(); // string
If you have the $route instance you can also do something like $route->currentRouteNamed(...)
See full API here:
https://laravel.com/api/8.x/Illuminate/Routing/Router.html#method_getCurrentRoute
I have a problem. When I use the Laravel browser test, I usually testing the date fields with this:
->script([
"document.querySelector('#date_of_show').value = '2019-01-01'",
]);
It works. But when the name of id contains square brackets, the selector does not find it. Example:
->script([
"document.querySelector('#items[0][date_of_show]').value = '2019-01-01'",
]);
I have trying a lot of style, but I can not solve it.
Can someone help me?
Thanks,
update :
the browser method:
$this->browse(function(Browser $browser) use ($user, $buyer, $buyerSearch) {
$browser
->loginAs($user)
->visit(route('buyer-search-properties.index', [$buyer, $buyerSearch]))
->check('items[0][check]')
->select('action', 'fixing-show')
->waitForText('Fixing Shows')
->script([
"document.querySelector('#items\\[0\\]\\[date_of_show\\]').value = '2019-01-01'",
]);
$browser
->click('Create');
});
You need to escape the brackets. Could you give this a try?
->script([
"document.querySelector("#items\\[0\\]\\[date_of_show\\]").value = '2019-01-01'",
]);
Edit: Here's a fiddle to show this in action.
Edit: I might be missing something, but would the following work?
$browser
->loginAs($user)
->visit(route('buyer-search-properties.index', [$buyer, $buyerSearch]))
->check('items[0][check]')
->select('action', 'fixing-show')
->waitForText('Fixing Shows')
->value('#items\\[0\\]\\[date_of_show\\]', '2019-01-01');
I solved! It works!
->script([
"document.querySelector('[name=\"items[0][date_of_show]\"]').value = '2018-12-20'",
]);
I'm using Codeigniter.I want to set href attr to something like :
<a href="/contact.html" >Contact</a>
But i get 404 error because i should write
Contact.
Where is some thing to fix this problem.
Any help please.
Assuming that you have a controller by the name Contact and you successfully extend the CI_Controller class, go to application/config folder and in config.php find:
$config['base_url'] = 'http://www.youdomain.com/';
Then in your internal links you should do:
Contact
If you are using javascript to make the redirect, put on top of the js file:
var host = 'http://www.yourdomain.com/';
Again:
window.location.href = host + 'contact';
If you're using codeigniter, you do not want to point to an .html file.
If you're using codeigniter correctly, you should use the helper methods that exist in codeigniter.
Instead of writing the anchor tag yourself, try this:
<?php echo anchor('contact', 'Contact'); ?>
to add the suffix to your controller in calling go to config/config.php and search for
$config['url_suffix'] = '';
and assign html to it to become
$config['url_suffix'] = 'html';
I'm using QueryPath to wrap a <div> around embedded videos on a site that contains a mixture of <object> and <iframe> embeds.
I tried the following code:
$content = qp($content)
->find('object,iframe,a.evdPlayer')
->wrap('<div class="splashBack"></div>')
->top('body')->children()
->html(); // << It's wanting to remove the </iframe> Grrr.
return $content;
But it seems to want to change my <iframe></iframe> code to <iframe />, which is messing things up for some reason. Is there a way to keep it from changing the tags it's wrapping?
Thanks in advance!
the ->html method does not set the LIBXML_NOEMPTYTAG flag when using DOMDocument::saveXML, if you need the closing tags you should use ->xhtml instead which passes this flag. eg
$content = qp($content)
->find('object,iframe,a.evdPlayer')
->wrap('<div class="splashBack"></div>')
->top('body')->children()
->xhtml();
return $content;
Found a solution that seems to work. It turns out that by inserting some content between the ... querypath recognizes the need for the closing tag and leaves it alone. It's a hack, but it works for now!
$content = qp($content)
->find('object,iframe,a.evdPlayer')
->text('[ video embed ]')
->wrap('<div class="splashBack"></div>')
->top('body')->children()
->html(); // << It's wanting to remove the </iframe>
return $content;