Get Data From URL
In this section we are going to get Data from the URL and display it on the
Demo page. With the use of Arguments we will get data from the URL and display it in the Body of the card we created in
Basic Page Styling.
The first thing we want to do is enable the Arguments in the AdminPanel -> PagesPermissions -> Page Permissions for
Demo. Add the following to the Arguments field within the Demo Page Permissions page:
To call get the data from the URL we need to add the following code to our
Demo.php file:
Code
/** Get data from URL **/
(empty($viewVars[0])) ? $argument1 = "" : $argument1 = $viewVars[0];
This will enable us to echo
$argument1 in the card body. Replace the "echo hello world" with the following:
Your
Demo.php file should look similar to the following:
Code
<?php
/** Set Meta Data **/
$meta['title'] = "Demo Page Title";
$meta['description'] = "This is the Demo Page Description";
$meta['keywords'] = "Demo, Page, Test, UserCandy";
$meta['image'] = "https://www.usercandy.com/UserCandyLogo.png";
/** Set Page Breadcrumbs **/
$data['breadcrumbs'] = "<li class='breadcrumb-item active'>".$meta['title']."</li>";
/** Get data from URL **/
(empty($viewVars[0])) ? $argument1 = "" : $argument1 = $viewVars[0];
?>
<div class="col-12">
<div class="card mb3">
<div class="card-header h4">
<?=$meta['title']?>
</div>
<div class="card-body">
<?=$argument1?>
</div>
</div>
</div>
Now if we go to http://localhost/Demo/ the Hello World text will be missing. If we add to the URL, http://localhost/Demo/HelloWorld/, we will see where it displays
HelloWorld in the card body. You can change HelloWorld in the URL and see what you can get away with.
If you get stuck and need help. Please use the UserCandy Forum.