Thursday, January 1, 2009

How to access one model from other model

I want to manage my user account from my entries index view i have
link on my entries/index page when i click on this link it will take
user to users/edit view how to do this my entries controller look
like
<?php
class EntriesController extends AppController {
var $name = 'Entries';
var $helpers = array('Html','Form','Javascript','Ajax');
var $components = array('RequestHandler');
function index()
{

$this->set('id',$this->Entry->User->find('all',array
('fields'=>'User.id','recursive'=>'0','conditions'=>array
('username'=>'pooja'))));
$this->Entry->recursive = 1;
$this->set('entries', $this->Entry->findAll());

}
function view($id = null)
{
if (!$id)
{
$this->Session->setFlash('Invalid id for Entry.');
$this->redirect('/entries/index');
}
$this->set('entry', $this->Entry->read(null, $id));

}

function add()
{
$this->set('sections', $this->Entry->Section->find('list',array
('fields'=>'Section.section','Section.id')));
if (empty($this->data))
{
$this->render();
}

else
{
$this->data['Entry']['name'] = $this->data['Entry']['File']
['name'];
$this->data['Entry']['type'] = $this->data['Entry']['File']
['type'];
$this->data['Entry']['size'] = $this->data['Entry']['File']
['size'];
if ($this->Entry->save($this->data))
{

$this->Session->setFlash('The Entry has been saved');
}
else
{
$this->Session->setFlash('Please correct errors below.');
}
if (move_uploaded_file($this->data['Entry']['File']
['tmp_name'], WWW_ROOT.'/files/' .$this->data['Entry']['File']
['name']))
{
echo "File uploaded successfully";
}
else
{
echo "There was an error uploading the file,
please try again!";
}
$this->redirect('/entries/index');
}

}
function edit($id = null)
{
if (empty($this->data))
{
if (!$id)
{
$this->Session->setFlash('Invalid id for Entry');
$this->redirect('/entries/index');
}

$this->set('sections', $this->Entry->Section->find('list',array
('fields'=>'Section.section','Section.id','recursive' => 1,'page' =>
1,)));
$this->data = $this->Entry->read(null, $id);
}
else
{

if ($this->Entry->save($this->data))
{
$this->Session->setFlash('The Entry has been saved');
$this->redirect('/entries/index');
}
else
{
$this->Session->setFlash('Please correct errors below.');
}


}
}

function delete($id = null) {
if (!$id) {
$this->Session->setFlash('Invalid id for Entry');
$this->redirect('/entries/index');
}
if ($this->Entry->del($id)) {
$this->Session->setFlash('Record deleted successfully');
$this->redirect('/entries/index');
}
}
function update_select()
{
if(!empty($this->data['Entry']['section_id']))
{
$section_id = (int)$this->data['Entry']['section_id'];
$options = $this->Entry->Submenu->find('list',array('section_id'=>
$section_id,'recursive' => 1,'conditions'=>array('section_id'=>
$section_id),'page' => 1,'fields'=>'Submenu.submenu'));
$this->set('options',$options);
}


}

}
?>
i don't have user_id in entries table
my index view as follows


<h2>Welcome <?php echo $id=$session->read('User')?></h2>
<h2>Count :</h2>
<div class="entries">
<?php
echo $html->css('default');
?>
<table cellpadding="0" cellspacing="0">
<?echo $html->tableHeaders(
array(

'Section',
'Submenu',
'Listitem',
'Detail',
'Actions'
)
);?>
<?php
$i = 0;
foreach ($entries as $entry):
$class = null;
if ($i++ % 2 == 0) {
$class ='class="altrow"';
}
?>
<tr <?php echo $class;?>>
<td><?php echo $entry['Section']['section']; ?></td>
<td><?php echo $entry['Submenu']['submenu']; ?></td>
<td><?php
if(strlen($entry['Entry']['Listitem'])>0)
{
echo $entry['Entry']['Listitem'];
}
else{
echo "----";
}
?></td>
<td><?php
if(strlen($entry['Entry']['Detail'])>0)
{
echo $entry['Entry']['Detail'];
}
else{
echo "----";
}
?></td>
<td class="actions">
<?php echo $html->link('View','/entries/view/' . $entry['Entry']
['id'])?>
<?php echo $html->link('Edit','/entries/edit/' . $entry['Entry']
['id'])?>
<?php echo $html->link('Delete','/entries/delete/' . $entry['Entry']
['id'], null, 'Are you sure you want to delete record' )?>
</td>
</tr>
<?php endforeach; ?>
</table>
<table style="border:none; width:90px;">

<tr class="actions"><td class="actions">
<?php echo $html->link('New Content entry', '/entries/add'); ?></td>
<td class="actions"><?php echo $html->link('Logout','/users/logout');?
></td>
<td class="actions"><?php echo $html->link('Manage Account','/users/
edit'.$form->value('User/id'));?></td>
<td class="actions"><?php echo $html->link('Update Counter','/updates/
index');?></td>
</tr>
</table>
</div>
can anybody help me its very urgent please try to help me
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: I can't view my view,why is it

for example
 

http://test.mysite.com     can show
 
what should I do?
 
Thanks
limeng
2009/1/1 李萌 <meiyousl@gmail.com>
hi,
every one,
happy new year.

I use a sub domain( http://test.mysite.com ),
I only can saw the default page,
besides it I can't saw any view,
why is it?
version 1.2 has any special settings?
or the cakephp can't use the sub domain?

Thanks
limeng



--
いつもお世話になっております。
李萌(り もえ)です。

以上です。よろしくお願いいたします。

李萌 (り もえ)

meet with all of you  in the season,
I think it's ついてる。

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

I can't view my view,why is it

hi,
every one,
happy new year.

I use a sub domain( http://test.mysite.com ),
I only can saw the default page,
besides it I can't saw any view,
why is it?
version 1.2 has any special settings?
or the cakephp can't use the sub domain?

Thanks
limeng

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: $cakeDebug variable undefined

Current Release of 1.2.

I am still having the same problem with renderElement() or element()

On Jan 1, 1:04 pm, "glenda guo" <gettyy...@gmail.com> wrote:
> what's the version number?
>
> if you want to use element,  it should like this, $this->renderElement
>
> On Thu, Jan 1, 2009 at 4:15 AM, gemmes <variouspix...@googlemail.com> wrote:
>
> > Hi all,
>
> > Nooby question. Why am I getting this error?
> > Notice (8): Undefined variable: cakeDebug [CORE/cake/libs/view/
> > elements/footer.ctp, line 10]
>
> > How I got error: I put code from bottom of my page into an element
> > called footer.ctp. I used $this->element('footer') to dispaly the
> > footer.
>
> > thanks
>
> > gemmes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: $cakeDebug variable undefined

what's the version number?


if you want to use element,  it should like this, $this->renderElement


On Thu, Jan 1, 2009 at 4:15 AM, gemmes <variouspixels@googlemail.com> wrote:

Hi all,

Nooby question. Why am I getting this error?
Notice (8): Undefined variable: cakeDebug [CORE/cake/libs/view/
elements/footer.ctp, line 10]

How I got error: I put code from bottom of my page into an element
called footer.ctp. I used $this->element('footer') to dispaly the
footer.

thanks


gemmes








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Conditional find on recursive belongsTo association

Hit it form the middle model.

IE paginate on the person model and you can view orgs and staff, thus
allowing you to view staff by org.

If that doesnt work for you then you might have other issues.

On Dec 31 2008, 5:16 am, WebbedIT <p...@webbedit.co.uk> wrote:
> Bump ... really need some help with this!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

$cakeDebug variable undefined

Hi all,

Nooby question. Why am I getting this error?
Notice (8): Undefined variable: cakeDebug [CORE/cake/libs/view/
elements/footer.ctp, line 10]

How I got error: I put code from bottom of my page into an element
called footer.ctp. I used $this->element('footer') to dispaly the
footer.

thanks


gemmes

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---