Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7090745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:38+00:00 2026-05-28T08:05:38+00:00

I have a link that calls: <a href=/coupons/print_coupon/<?php echo $coupon[‘id’]; } ?> id=print><span style=margin-left:24px;>Print</span></a>

  • 0

I have a link that calls:

<a href="/coupons/print_coupon/<?php echo $coupon['id']; } ?>" id="print"><span style="margin-left:24px;">Print</span></a>

It plugs in the correct id, and my route sends it to the correct view file. I have a debug command to show the entire array for the print page, but I’m getting an empty array. Here is my controller code:

<?php 
class CouponsController extends AppController {
    public $name='Coupons';
    public $uses=array('User', 'Coupon', 'Restaurant');
    public $layout='pagelayout';


    public function print_coupon($name=null) {
      $this->set('title', 'Print your coupon');
      $f=$this->Coupon->find('first', array('conditions'=>array('Coupon.id'=>$this->params['id'])));
      $this->set('name', $f);
    }

}
?>

Here is my Coupon Model:

<?php
class Coupon extends AppModel {
    public $name='Coupon';
    var $belongsTo=array(
    'Restaurant'=>array (
        'className'=>'Restaurant',
        'foreignKey'=>'restaurant_id'
        )
    );
}

?>

and here is my Restaurant Model:

<?php

class Restaurant extends AppModel {
public $name='Restaurant';
var $hasMany=array(
    'Coupon'=>array(
        'className'=>'Coupon',
        'foreignKey'=>'restaurant_id'
        )
);
var $belongsTo=array(
'User'=>array(
'className'=>'User',
'foreignKey'=>'user'
)
);

}


?>

I have tried variations using

 <a href="/coupons/print_coupon/<?php echo $res['Restaurant']['coupon']; } ?>" id="print"><span style="margin-left:24px;">Print</span></a>

along with in my controller:

public function print_coupon($name=null) {
      $this->set('title', 'Print your coupon');
      $f=$this->Coupon->find('first', array('conditions'=>array('Coupon.id'=>$this->params['id'])));
      $this->set('name', $f);
    }

as well as a few others, and whenever I debug($name) I get an empty array. I have had no problems associating Coupon with my other models for other tasks yet, but i think something may be wrong with my Restaurant Model.

For reference, I have these are equal to each other:
Restaurants.coupon = Coupon.id
Coupon.restaurant_id=Restaurant.id

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:05:39+00:00Added an answer on May 28, 2026 at 8:05 am

    The first anchor code you posted has a curly brace that shouldn’t be there. When you use this:

    <a href="/coupons/print_coupon/<?php echo $coupon['id']; ?>" id="print"><span style="margin-left:24px;">Print</span></a>
    

    It should yield some url that’s like this:

    /coupons/print_coupon/75
    

    Then in your CouponsController that 75 turns into the $name in your print_coupon parameters (with default routing settings), I recommend changing that to $coupon_id, so your function should look like this:

    public function print_coupon($coupon_id) {
      $this->set('title', 'Print your coupon');
      $f=$this->Coupon->find('first', array('conditions'=>array('Coupon.id'=>$coupon_id)));
      $this->set('name', $f);
    }
    

    Now $name should be accessible in your view. With this code above, $name won’t exist within the controller.

    I don’t think $this->params exists in Cake 2.*. debug($this->request->params); You can get the params from there in the controller, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have a link that opens a Thickbox... <a href=page.php?tag=lists-element&keepThis=true&TB_iframe=true&height=450&width=500> Everything works with this
I have a page with a Print link that takes the user to a
I have a a link that calls a onmouseover javascript function that makes a
Say I have an anchor link like: <a id=page-contact rel=shadowbox;width=640;height=400 href=/contact.php>link here</a> How would
I have a login link that fires a javascript function that calls a logout
I have a href tag that goes like this : href=download.php?file={$sp->attachment_1}&flag=ds&r_id={$userid}&scpl_id={$sp->sp_id}; that works and
I have a link that is located inside a content control. This link calls
I have a method song_link that calls link_to internally. I want the caller to
I have quite a few cells that link to other worksheets/books, etc with standard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.