I want to redirect www.myhost.com/g/:id to www.myhost.com/jobs/view/:id. Currently the following code does that fine:
$routes->connect(
'/g/:id',
['controller' => 'Jobs', 'action' => 'view'],
['pass' => ['id'], 'status' => 301, 'persist' => ['id']]
);
However, in the addressbar it still shows www.myhost.com/g/:id. I'd like it to show the full URL (www.myhost.com/jobs/view/:id), not the 'shortened' URL.
How would I adjust the code to do the above?
Router::connect is a way of connecting one route to another, without a full redirect.
If you're wanting redirect a user and have that exposed to them, you can use Router::redirect(). It automatically will set the 301 status.
$routes->redirect(
'/g/:id',
['controller' => 'Jobs', 'action' => 'view'],
['pass' => ['id'], 'persist' => true]
);
Related
I have this code snippet from a symfonycasts video tutorial:
#[Route('/')]
public function homepage(): Response
{
$tracks = [
['song' => 'Gangsta\'s Paradise', 'artist' => 'Coolio'],
['song' => 'Waterfalls', 'artist' => 'TLC'],
['song' => 'Creep', 'artist' => 'Radiohead'],
['song' => 'Kiss from a Rose', 'artist' => 'Seal'],
['song' => 'On Bended Knee', 'artist' => 'Boyz II Men'],
['song' => 'Fantasy', 'artist' => 'Mariah Carey'],
];
var_dump($tracks);
return $this->render('home/homepage.html.twig', [
'Heyyyy' => 'Waaasssup',
'tracks' => $tracks,
]);
}
I know that i should not use a var_dump but i wanted to try anyway and it actually displays the dump on the browser page but i don't get how...
I thought that the content of the final page would only be the content's value from the Response object that is returned by the render() method? So how can the var_dump content be displayed on the final page?
Am i missing something? Thanks.
I tried to understand... and it led to nothing!
#Jakumi is right, the PHP Interpreter will prepend the dumped output before anything else in the response content.
See the php documentation for more information about var_dump().
It also states, that you can control the output by using the Output Control of php. (see PHP Output Control)
Currently, I would like to have redirected CV links to my AWS S3 bucket. I use Sonata Admin.
With the URL I am redirected on
->add('cvName', 'url', [
'url' => "https://s3.eu-west-3.amazonaws.com/*****/",
'attributes' => ['target' => '_blank']
])
Without I am redirect on the CV name.
->add('cvName', 'url', [
'attributes' => ['target' => '_blank']
])
I would like that when you click on the link, be redirected to the address "https://s3.eu-west-3.amazonaws.com/*****/ + CVNAME"
Thank you very much for your answer.
Try str_replace:
url = str_replace('*****', CVNAME, "https://s3.eu-west-3.amazonaws.com/*****/")
i am trying to create webhook using the api call inlaravel but it gives me the error "The requested URL returned error: 406 Not Acceptable".
my code is as bellow.
$webhookData = [
'webhook' => [
'topic' => 'app/uninstalled',
'address' => url('/uninstall'),
'fields' => 'name',
'format' => 'json'
]
];
$uninstall = $sh->call(['URL' => 'https://' . $shop . '/admin/webhooks.json', 'METHOD' => 'POST', 'DATA' => $webhookData]);
There are certain things you need to take care of while creating the Shopify webhooks.
The address field should be a globally accessible URL (ex: https://example.com/webhook/uninstall.php)
You can not give localhost links for creating webhooks.
I think the address field is not passed with a valid URL in your post request.
I am new to WordPress and learning by implementing. Today I have created a list of archives using wp_get_archives for a custom post type. The list comes up fine!
$args = array(
'type' => 'monthly',
'limit' => '15',
'format' => 'html',
'before' = '',
'after' => '',
'show_post_count' = true,
'echo' => true,
'order' => 'DESC',
'post_type' => 'travelog'
);
wp_get_archives($args);
Now I am stuck with two things and no idea how to solve them!
[ A ]
What I want to accomplish:
I want to achieve the functionality that when somebody clicks on an item from the list it would take him to another page with posts listed for that period only.
What is happening:
WordPress takes me back to site's home page.
How can I tell WordPress to go to a page and display the posts for that period. Posts can be custom post types as well.
[ B ]
What I want
With a Custom Post Type passed ('post_type' => 'travelog') link for each item be like http://local.tourplanner.com/2017/03/travelog
What I am getting
It is like http://local.tourplanner.com/2017/03/?post_type=ravelog
With 'post_type' => 'post', however, there is no query string added to and they look like http://local.tourplanner.com/2017/03
If possible I would love to achieve this without using any plugin.
Looking forward to your suggestions.
I have got a unique issue. In my drupal site, I have got a lot of nodes displayed in a teaser and for each node, I am using a table with a pager. The problem is, on initial load of the page, the table sort doesn't work. However, if I use the pager and move to a different page and then back, then the sorting works.
I investigated this issue and found out that on initial load, the url for the header links use the primary link, which is: mysite.com/node?sort=asc&order=Name. After I click on the pager, then the url for the header links, changes to this: mysite.com/mycallbackfunction?_=1348208999187&page=1&nid=13&pager_id=1&sort=desc&order=Name
If you notice, the url obviously are different, which is okay, but the main thing is, the nid is missing in the initial load. I would like the table headers to use the pager url, or some url that I specify, so the nid would appear in both cases as the function returns nothing if there is no nid.
This is the relevant code in mycallbackfunction which displays the table:
//Attach a theme table
$html = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
"class" => array(
"my_table_box"
),
"cellspacing" => '0',
"cellpadding" => '0'
)));
//Pager theme
$html .= theme('pager', array(
'element' => $pager_id,
'parameters' => array(
'nid' => $nid,
'pager_id' => $pager_id),
'quantity' => ceil($count/5)
));
Hope someone might have an insight into this weird problem.
You can pass the custom parameter in theme('pager') function.
<?php
// e.g.
theme('pager', array('parameters' => array('nid' => $nid))
?>);
Let me know if you are looking for something else.
Good Luck!
-Imran