How to put an external link + the parameter - symfony

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/*****/")

Related

Fake URL Shortener

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]
);

how to create uninstall webhook in shopify using laravel wrapper?

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.

WordPress - How do I retrieve custom post type posts from output of wp_get_archives

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.

Facebook Posting using FB API phpSDK

i created my app on fb with permissions ready to publish on users behalf, the thing is, a regular post has Like and Comment links, like buttons on bottom of the post, i want to add my custom link : VOTE NOW, its a poll post
how can i do that?
someone gave an answer but for js sdk not php, n i cant find it on facebook dev documentation
some gave a close enough solution, but ddnt seem to work on php with modifications
FB.ui({
method: "feed",
link: "LINK_URL",
...
actions: [
{ name: "Read Now", link: "URL TO THE READ NOW " }
]
}, function(response) { console.log(response); });
It seems it's working with /me/feed but with my custom /me/xxxxxx:submitted_a_poll/ its not working
When you make a call with the PHP SDK, you also pass a similar set of parameters:
$attachment = array(
'link' => 'http://your-cool-site.com',
'description' => 'This is the description',
...
'actions' => array(
array(
'name' => 'Vote Now!',
'link' => 'http://your-cool-site.com/vote.php'
)
)
);
$result = $facebook->api('/me/feed/', 'post', $attachment);
All you really have to do is add the relevant action settings to your parameters.

Redirect to a new page from within a Drupal site

I'm working with a Drupal site, and we want to set up a special URL that redirects to an external site. In other words, if http://www.mysite.com is our Drupal site, we want to have http://www.mysite.com/external redirect to the external site.
I have very little experience with Drupal and have no idea how to set this up. Any help is appreciated!
If all you want is to redirect the users to the same site, when they follow a link that takes them to http://www.example.com/external, then you can implement hook_menu() using code similar to the following one:
function mymodule_menu() {
$items = array();
$items['external'] = array(
'title' => 'Redirect',
'page callback' => 'mymodule_redirect',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_redirect() {
drupal_goto($url, array('external' => TRUE));
}
If the URL to which the users are redirected depends from a value passed in the URL, then you can use code similar to the following one:
function mymodule_menu() {
$items = array();
$items['external/%'] = array(
'title' => 'Redirect',
'page callback' => 'mymodule_redirect',
'page arguments' => array(1),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_redirect($id) {
// Calculate $url basing on the value of $id.
drupal_goto($url, array('external' => TRUE));
}
You could install the Path Redirect module which will let you do exactly that, no coding required.
If you're using Drupal 7, you want the Redirect module.
If you want to redirect an existing URL, another way via the UI is to use the popular Rules module:
e.g: "Reaction Rule" export, redirect homepage to external domain:
{ "rules_redirect_homepage" : {
"LABEL" : "Redirect homepage",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "init" : [] },
"IF" : [
{ "data_is" : { "data" : [ "site:current-page:url" ], "value" : [ "site:url" ] } }
],
"DO" : [ { "redirect" : { "url" : "http:\/\/example.com" } } ]
}
}
Can be imported at admin/config/workflow/rules/reaction/import
you have to download the modules that Clive mentioned
and you can add a menu link that redirect to external site without any module
1- Go to admin/structure/menu
2- choice the menu that you want to add the url to and click on {add Link}
3- add the external Path in "path" field like the following "http://yahoo.com"
good luck
If you're using Drupal 8, you can use the class RedirectResponse to do this.
use Symfony\Component\HttpFoundation\RedirectResponse;
The details of how to implement, you can read this post How to sample redirect page on drupal 8

Resources