Making database results as html links - view

I am new to cakephp and I want my database results to be shown as a link so that if a user clicks on the result, he/she should be redirected to a different page which is in different controller and have a different view. Any Help??
For example: I have this line of code that displays the result from the database.
<?php echo $Menu['Menu'] ['menuname']; ?> </td>
I want the users to see this menuname as a link which will redirect to the menu items page.

This is a plane php code (programming language). So, you can add any link to any page you want at the menu. For example replace this code with:
<?php echo ''.$Menu['Menu']['menuname']. ''' </td>
Or post what exactly link you want to show for users.

Related

Roles and permissions issues in laravel project

I am working on a laravel project. I have a side menu that is persistent across all pages. However the menu items to be shown is dependent on the role assigned to the user. I achieved that by doing this:
<?php
/**$links = Session::get('links'); **/
use Illuminate\Support\Facades\DB;
$id_hr_employee= Auth::user()->id_hr_employee;
$links = DB::select("select a.link as links from sys_menu_links as a a.id_hr_employee = $id_hr_employee)
");
?>
#if(isset($links))
#foreach($links as $link)
<li><hr class="light-grey-hr mb-10"/></li>
#include("$link->links")
#endforeach
#endif
This works quite alright. However, if someone enters a route to a menu (that he is not assigned to) on the address bar, he sees that page.
Please how do I prevent this?
i would highly recommend you using laratrust: https://laratrust.readthedocs.io/en/4.0/.
And to secure your sides: 1.option work with middelware to Block your admin views 2. Option Check for permission in the Controller files.
As a guidance you could look up this tutorial: http://itsolutionstuff.com/post/laravel-52-user-acl-roles-and-permissions-with-middleware-using-entrust-from-scratch-tutorialexample.html
greetings

Send back value from controller when submit form codeigniter

here is a question that I am not able to find a way to do it. At the home view, I have a php section that will echo out if users input is just signed in when they submit form. But when I am doing this, it will give out a undefined error, because that controller is not yet executed.
This is my home view.
<?php include('header.php'); ?>
<?php echo $sign_in_results;?>
<?php include('forms/forms.php'); ?>
<?php include('footer.php'); ?>
This is my sign in controller, will get execute when submit pressed, the modal will return true or false.
function form_sign_in_controller(){
$this->load->model("form_sign_in");
$database_insert_results = $this->form_sign_in->check_user_detail_with_db();
$data['sign_in_results']= $database_insert_results;
$template = $this->load->View('main_view', $data);
}
I tried to use if(isset()).. The error is gone, but that section does not echo out anything. Any idea? Thanks
validate the data that comes from your sign in form. Never pass data from a form directly into a database query.
validating the data will tell you if the form has correct values. if it does not, then show the form again.
form data is validated - query your database
there are 3 possible results - you got a match OR you did not get a match OR there was an error. Check for these 3 different conditions, and then show the appropriate view.

Displaying a static block as a popup window in Magento

I'm trying to display a static block in Magento as a popup window, but can't seem to get the code to work.
I've found code in various places on the internet that seems to be fairly close to what I want but I can't get any results. I've used the basic code to return the "top links" to my site so I know that the basics work.
I've created a delpopup.php script in my Magento root folder and put in this code:
<?php
require_once('app/Mage.php');
umask(0);
$layout = Mage::app()
->getLayout();
$layout
->getUpdate()
->addHandle('default')
->load();
$layout
->generateXml()
->generateBlocks();
echo '<p>before</p>';
echo $layout
->createBlock('cms/block')
->setBlockId('delivery-info')
->toHtml();
echo '<p>after</p>';
?>
Unfortunately the code doesn't display the static block. That part of the output is blank.
The idea is that I can place a link in a regular page in Magento and have my delivery into pop up. Like this:
<a title="" onclick="popWin('http://www.mysite.com.au/delpopup.php', 'deliveryinfo', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" href="#">Delivery Info</a>
Basically I want to be able to display a static block in a popup window that uses my Magento site's theme. Any ideas would be greatly appreciated.
As I thought, the problems lies on incorrect Block Id.
Now that the cms is able to be shown.
So now the question is: how to get the theme work?
Not really sure what do you mean by theme, if what you mean is css that was included in <default> tag, you can use:
Mage::getDesign()->setTheme('your theme');
echo $layout->getBlock('head')->toHtml();
After the xml has been finished generated, it means put that code after:
$layout
->generateXml()
->generateBlocks();
I'd first setup a controller and block(s) to render the type of layout that you want to throw within the popup. So, instead of doing this within a standalone php file, do it within the regular mage framework within a specific controller action.
Then, once you have that working - the question is how to pull it into a popup. I'd go with maybe a nice jquery popup widget that allows you to specify a URL to hit - and then just pass in the one that you prepped for step 1 above.
You may want to look at adminhtml/default/default/template/popup.phtml for inspiration. That's actually a popup template for the admin, not the frontend, but you can see what they've done.
They're pulling in some standard magento blocks including the head block, which should pull in all your CSS and JS, in order to give you the general color scheme / look&feel of your frontend, but without all of the navigation, etc.

How to move the estimate shipping block to a CMS page in Magento?

I'm trying to move the 'Estimate Shipping' block, that usually sits in the Cart, to a CMS page.
I've successfully moved the form, however, upon clicking the 'Estimate..' button, I get redirected to the Cart.
I've tried changing
action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>"
to the cms page url:
`action="getUrl('delivery/estimatePost') ?>"`
and also a general:
action="<?php echo $this->getUrl('*/*/estimatePost') ?>"`
but then I just get a 404.
You should keep action="getUrl('checkout/cart/estimatePost') ?>" or otherwise you will need to create a different controller action which generate a different block content to allow to display in your cms block but it's not so easy as you try to do.
The string checkout/cart/estimatePost means module/controller/action, if you change that of course he won't find your page. That's why you need to develop a solution more complex with a mix of controller and based on the block classes used while the action estimatePost is called.

CodeIgniter - sending variable from controller to a view which use template

I have the following problems.
I am using the following template for my application:
<?php $this->load->view('backOffice/bo_header_in');?>
<?php $this->load->view($bo_main_content);?>
<?php $this->load->view('backOffice/bo_footer_in');?>
When I send data from the controller, to edit a record, I have the following code:
$data['userid'] = $this->back_office_users->getOneUser($userid);
$data['bo_main_content'] = "backOffice/edituser_view";
$this->load->view('backOffice/bo_template_in', $data);
Now, in my view, where I want to edit the record, I am getting it all right, my form is filled with the user name and password but.... on the top of the page, I get displayed the userid, username, userpassword, which is not what I want. Can anyone help me how can I send the data from my controller to my view, so I can have only my form filled, and not have the userid,username and password diplayed on the top of the page?
What you have shown looks ok. Search your models/controllers for a var_dump and re-look at the code in your view for a print_r. I typically do this during development to see the variable contents.

Resources