url pass in the file for get a page - php

I am creating a site in which I would like to go to another page via a custom menu. My menu code for the views/layout/main.php is:
array('label'=>'create wireframe', 'url'=>array('wireframes/create'), 'visible'=>!Yii::app()->user->isGuest),
A user can go to the wireframe creation page, but it passes the url index.php?r=user/wireframes/create
but I only want index.php?r=/wireframes/create. How can it pass the url? Are there any additions that I missed?

I guess you can try
'url'=>array('/wireframes/create').

Related

how to change WordPress URL on all pages?

how to change WordPress URL on all pages? suppose we have a xyz.com. Now I want something like xyz.com/test when customer visiting to xyz.com. and for all newly created pages must be something like xyz.com/test/Newpage.
For example, if your new directory is called application, you would visit www.your-site.com/application/wp-admin or www.your-site.com/application/wp-login.php.
Update /wp-blog-header.php to include your new directory. For example, if your new folder is called application, you would change the file path to this: /application/wp-blog-header.php.
Change this line in the index.php int the root folder.
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
If you want to change the Wordpress URL for all pages then you can follow below step,
Login to WordPress
Open the existing page or create a new page
Enter a Title if necessary
Save the page, this will automatically create a URL
Look directly under the title field, you will see Permalink: followed by the URL
Click the Edit button behind the link
Type in the new URL and click OK
Save the page or post
Customize Permalink Structure, You can choose "Post name" option.
Post name - An example of the post name structure is http://www.sample.com/sample-post
Hope this will helps you.

Laravel how to prevent href link gets appended with current url

Let's say my project root is http://localhost/laravel-project
In the project I have navigation menu, the sample format of the link is
home"
So when I click the link the url on my browser is http://localhost/laravel-project/home
I do not know why if I have another link
home" and the route is Route::get('/invoice/show/{id}', 'Frontend\CommonController#show');
when I click the link, the previous home link will become
http://localhost/laravel-project/invoice/show/member it's supposed to be http://localhost/laravel-project/home.
The inside show method :
public function show(){
return view('frontend.invoice', ['subaccounts' => $this->subaccounts, 'menus' => $this->menus]);
}
I have tested it, the cause of the problem is the segments on the link invoice/show/1 if the link is only invoice then everything is fine.
Anyone knows what is wrong and how to solve this issue ?
Note : I am using a blade template
I managed to solve the problem by using the function {{url('linkName')}} in the link.

Wordpress register user only from a secret url

I send a special url to my users who want to register on my wordpress website. So, I want to send them a url with a variable invited=true appended in it like: http://example.com/wp-login.php?action=register&invited=true so that only those who have this url can register otherwise they are redirected to main page.
So if invited=true is in the url of registration page then go ahead, otherwise redirect to main website page. like:
if (!isset(GET('invited'))
redirect $website_name;
if (GET('invited') != true)
redirect $website_name;
//go ahead with the rest of the registration page code
where do I put this validation code? and what is the variable in WordPress for website name? so that I can put it in redirect instead of hard coding my website domain.
Please do not worry if someone else uses the url with variable, that is not an issue.
If you are using a theme you "own", like a custom theme or a childtheme, you can hook this function to the login_head hook from your themes functions.php:
https://codex.wordpress.org/Plugin_API/Action_Reference/login_head
If you don't "own" the theme, this will be overwritten the next time you update and in this case you will be looking at writing a plugin, which is a fair bit more complicated...:
https://codex.wordpress.org/Writing_a_Plugin
Try this code in your theme functions.php:
add_action('init','redirectUrl');
function redirectUrl(){
if($_request['invited'] != true){
$url = 'exampleurl.com';
wp_redirect($url):
}
}

Read POST data in Wordpress page

I am trying to write a plugin for wordpress. I have a problem i can't solve.
Inside plugin i habe added a shortcode that show a form.
function showForm() {
echo '<form method="post" action="www.example.com/myDestinationPage">';
[...]
}
add_shortcode( 'ShowFormSC' , 'showForm' );
After that, in a page, i added the shortcode and it works perfectly. ;-)
Now the problem: how can i read POST data in myDestinationPage (another wordpress page)?
In Php would be very simple ... but in wordpress I do not know how to do.
Second problem: myDestinationPage must be a real wordpress page with another shortcode inside, or can be defined as a "virtual" page inside my plugin?
Thank you for your help!
Best Regards,
Simone
www.example.com/myDestinationPage needs to be edited to recieve the post data, just as in any other php script, wordpress or not. If 'myDestinationPage' resolves to dynamic wordpress content, then you are in muddy waters.
Let's say, myDestinationPage is a wordpress Post. That "page" doesn't exist as a file, it comes directly from the database.
You could write a shortcode which handles this though:
add_shortcode('post_parser', 'postParser');
. . .
function postParser() {
filter_input(INPUT_POST, 'my_post_value');
//do something
}
Then, you just add the '[post_parser]' shortcode to the myDestinatioPage Post. (You mentioned it's a wordpress page, but page & post are both WP_Post objects.)
Another option is to put your post processing code in the post.php (or whichever template myDestinationPage is).
1st answer: you can directly use $_POST in wordpress like in php.
2nd answer: Yes you can. If you want to use pages in your plugin, use plugins_url() to generate the path for form action.
https://codex.wordpress.org/Function_Reference/plugins_url

Wordpress Get URL Footer File

I need to access the footer inside a wordpress theme via a url. Ideally it would just render the footer data and nothing else, alternative suggestions welcomed though.
To add some context, the data will be fetched through the url and a script will read the markup. This data will then be cached and available through Magento where it is needed to be displayed..
Is there a url path that will display it or should I make a new page that can be called via the base-url+the-page-name???
There's nothing built in to do that. You could use the AJAX API in your theme or a plugin and accomplish it.
You hook into an action that gets sent as a URL or POST data parameter and then make a request to yoursite.com/path/to/wordpress/wp-admin/admin-ajax.php.
<?php
add_action('wp_ajax_so20495429_display_footer', 'so20495429_display_footer');
add_action('wp_ajax_nopriv_so20495429_display_footer', 'so20495429_display_footer');
function so20495429_display_footer()
{
get_footer('ajax');
}
This will work for all users, logged in or not, despite the wp-admin URL. Here is code above wrapped up in a plugin.
what you can do is make a wordpress custom page template.
If you dont know how heres a little tutorial : http://www.expand2web.com/blog/custom-page-template-wordpress/
Now you want the custom page template to only load the footer (add the html, head and body opening tags yourself)
if you create a new page with your page template seletced it will only output the footer.
Hope you can get it to work
Greetings
merijn
What about $footer_url=get_template_directory_uri().'/footer.php'; ?

Categories