Yii Framework Forum: Need Help With Pdf Extension - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Need Help With Pdf Extension Rate Topic: ***** 1 Votes

#21 User is offline   dyooolicious 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 18-October 12
  • Location:Surabaya, East Java, Indonesia

Posted 16 November 2012 - 04:46 AM

View PostKeith, on 16 November 2012 - 04:41 AM, said:

Can you post the view code where you're creating the link?


I put it into some view like admin view, index view, etc.
this is from index view :
<?php
/* @var $this UserController */
/* @var $dataProvider CActiveDataProvider */

$this->breadcrumbs = array(
    'Users',
);

$this->menu = array(
    array('label' => 'Create User', 'url' => array('create')),
    array('label' => 'Manage User', 'url' => array('admin')),
    array('label' => 'Download Member Card', 'url' => array('pdf', 'id' => $model->id_user)), //here it is
);
?>

<h1>Users</h1>

<?php
$this->widget('zii.widgets.CListView', array(
    'dataProvider' => $dataProvider,
    'itemView' => '_view',
));
?>

keep learning, trying and praying makes you keep going !
tweet me : @dyooolicious
http://ini-infonya.blogspot.com/
0

#22 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,311
  • Joined: 21-February 11
  • Location:Greece

Posted 16 November 2012 - 04:49 AM

View Postdyooolicious, on 16 November 2012 - 04:39 AM, said:

hmm.. last one question. when I change 'id'=>1 with 'id'=>$model->id_user, it doesn't give me the user ID. I've tried to check it with firebug, and I see no user Id too in the link. how can I fix this?

thanks in advance.


Are you sure tha the $model is not null? check with var_dump ($model) and see if related user has id
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#23 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,511
  • Joined: 04-March 10
  • Location:UK

Posted 16 November 2012 - 04:51 AM

I would guess you're not passing a $model instance into the view. Realistically, it'd make more sense to use the logged in user's ID, so:

'url' => array('pdf', 'id'=>Yii::app()->user->id)


Of course, you'll need to ensure it's only used when a user is logged in; ie. Yii::app()->user->isGuest is false.
0

#24 User is offline   dyooolicious 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 18-October 12
  • Location:Surabaya, East Java, Indonesia

Posted 16 November 2012 - 04:55 AM

View PostKeith, on 16 November 2012 - 04:51 AM, said:

I would guess you're not passing a $model instance into the view. Realistically, it'd make more sense to use the logged in user's ID, so:

'url' => array('pdf', 'id'=>Yii::app()->user->id)


Of course, you'll need to ensure it's only used when a user is logged in; ie. Yii::app()->user->isGuest is false.


that url give me this error : Property "CWebUser.id_user" is not defined. :mellow:
I already add this !Yii::app()->user->isGuest
keep learning, trying and praying makes you keep going !
tweet me : @dyooolicious
http://ini-infonya.blogspot.com/
0

#25 User is offline   dyooolicious 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 18-October 12
  • Location:Surabaya, East Java, Indonesia

Posted 16 November 2012 - 04:56 AM

View PostKonApaz, on 16 November 2012 - 04:49 AM, said:

Are you sure tha the $model is not null? check with var_dump ($model) and see if related user has id


no, it's not null. if it is null, then there are nothing appears in my view
keep learning, trying and praying makes you keep going !
tweet me : @dyooolicious
http://ini-infonya.blogspot.com/
0

#26 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,511
  • Joined: 04-March 10
  • Location:UK

Posted 16 November 2012 - 04:57 AM

You're not using id_user. Make sure you've used id, not id_user.
0

#27 User is offline   dyooolicious 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 18-October 12
  • Location:Surabaya, East Java, Indonesia

Posted 16 November 2012 - 05:00 AM

View PostKeith, on 16 November 2012 - 04:57 AM, said:

You're not using id_user. Make sure you've used id, not id_user.


wow, you like a genie that knows everything LOL.
thanks it works now ;D
keep learning, trying and praying makes you keep going !
tweet me : @dyooolicious
http://ini-infonya.blogspot.com/
0

#28 User is offline   KonApaz 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,311
  • Joined: 21-February 11
  • Location:Greece

Posted 16 November 2012 - 05:01 AM

View Postdyooolicious, on 16 November 2012 - 04:56 AM, said:

no, it's not null. if it is null, then there are nothing appears in my view


what is shown with var_dump? Does the user id show in properly way?
Yii is the best php framework in the world!
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users