Re: can't pass variable to default.ctp

2012-01-17 Thread mklappen
Thanks for info, i was missing "parent::beforeFilter" in the
pagesController. After adding that, setting the view variables from
the AppController beforeFilter worked.


On Jan 17, 4:26 pm, euromark  wrote:
> you shouldnt set any view vars to the view in beforeFilter
> this callback is not always triggered - beforeRender, though, is.
>
> also make sure you ALWAYS call the "parent::before..." method from any
> of your controllers in those callbacks.
> thats probably what is missing in your case
>
> On 17 Jan., 23:20, jeremyharris  wrote:
>
>
>
>
>
>
>
> > If you're receiving undefined variable errors, track where those errors
> > come from. It likely lies in one of your two functions, _usersUsername or
> > _loggedIn. One of those methods must be relying on a variable that is set
> > after that beforeFilter is run. Stack traces are your friend.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


can't pass variable to default.ctp

2012-01-17 Thread mklappen
Hello,

I recently installed cakePHP 2.0.5 and I'm trying to send variables
from my AppController to my default.ctp layout. (setting up some Auth
components)

However when I put the set in $this->set in the beforeFilter I receive
"Undefined variable" error. However when I add them to a beforeRender
function it works.

Am I doing something wrong? has this changed from Cake 1.3 to Cake
2.0.5?

AppController.php
//does not work
  public function beforeFilter() {
$this->set('users_username', $this->_usersUsername());
$this->set('logged_in', $this->_loggedIn());
$this->Auth->allow('index', 'view');
  }

//works
  public function beforeRender() {
$this->set('users_username', $this->_usersUsername());
$this->set('logged_in', $this->_loggedIn());
}

default.ctp

    Welcome,  | Html-
>link('Logout', array('controller'=>'users', 'action'=>'logout')); ?>

Thanks!
mklappen

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How to setup multiple HABTM relationships between two tables

2011-01-13 Thread mklappen
Thanks for replies... I added a two boolean columns to join table for
"owns" and "wants"

Thanks again!!

On Jan 13, 3:13 am, Jeremy Burns | Class Outfit
 wrote:
> You could consider adding a new column to your joining table that contains a 
> tinyint. By default the value of that field is 0 (which indicates wants) but 
> changes to 1 when he owns it. This assumes that someone can no longer 'want' 
> something when they already 'own' it.
>
> Jeremy Burns
> Class Outfit
>
> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>
> On 13 Jan 2011, at 07:14, Zaky Katalan-Ezra wrote:
>
> > If you go with the status columns you need two boolean columns one for own 
> > and one for want, its a possible solution.
> > If you want to use two table you can create users_want and users_own.
> > The relation for each table should looks like it would be for items_users.
> > The reason to prefer one implementation depend on your over all design and 
> > data distribution.
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
> > with their CakePHP related questions.
>
> > 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+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How to setup multiple HABTM relationships between two tables

2011-01-12 Thread mklappen
Hi All

I'm having a little difficulty conceptualizing the relationships when
setting up a database/models, for a app I'm starting to develop. If
I'm creating a basic inventory management application I have the
following:

Table Name | Columns
users | id, user_name, email, etc...
items | id, name, description, etc...
items_users | id, item_id, user_id

I want a user to be able to mark items as "owns" or "wants" and a user
can own many items and items can be owned my many users. Similarly
"wants" would have same HABTM relationship between users and items.

Now I can set up the HABTM relationship table "items_users" but that
will only get me one relationship between users and items. (either the
"owns" or "wants"). In order to get the second relationship type do I
need to set up a second relationship table? if so what would the
naming conventions be?

Or do I add a another column to "items_users" table called
"itemstatus" and have values such as "owns", "wants", "owns &
wants"...

More or less looking for the best approach and/or other suggestions.

Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


How to incorporate site home page with custom cakephp cms

2010-01-19 Thread mklappen
I have created a fairly basic custom content management app using
CakePHP that allows me to enter information into my database through a
number of different web forms. (it's a gaming website that has game
info, reviews, etc...). The app is named 'CMS'.

I developed this mostly to learn the basics of CakePHP but now that I
have it working and have some data, I was wanting to hook it up to my
homepage design so it pulls in the data I've entered into the DB via
my CMS app, However I'm having some 2nd thoughts visualizing how this
should be set up.

Is it better to create a new cakephp app, building the home page and
other pages using the same tables I created/populated in my CMS app?
Or should I start coding my site design into an index.php file with
sql queries to pull content from DB (not using cakephp) and upload
that file to my web server root?

Any tips/recommendations are greatly appreciated,

Thanks!
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: neighbors sort

2009-10-01 Thread mklappen

I think I'll have to write my own function as well. kind of put this
on the back burner for now and will come back to it once I've finished
coding the rest of the app.
Thanks for the reply.

On Sep 28, 10:43 am, "euromark (munich)" 
wrote:
> i ended up writing some highly complicated function for it myself
> not only for your problem, but for "correct" neighbors in general
>
> if you use UUIDs you dont have sorted IDs anyway
> and sometimes you have to sort by more than just 1 field etc..
>
> On 25 Sep., 17:27, mklappen  wrote:
>
> > Hi
>
> > Is there a way I can sort a query and then have the find (neighbors)
> > based on that sort?
>
> > I'm trying to sort my results by title and then would like prev/next
> > elements returned by neighbors to be the prev/next title in alpha
> > order. However, neighbors is returing the prev/next ids which are not
> > in alpha order.
>
> > $this->Game->find('neighbors',array
> > ('fields'=>'Game.title','order'=>'Game.title ASC'));
>
> > Thanks!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



neighbors sort

2009-09-25 Thread mklappen

Hi

Is there a way I can sort a query and then have the find (neighbors)
based on that sort?

I'm trying to sort my results by title and then would like prev/next
elements returned by neighbors to be the prev/next title in alpha
order. However, neighbors is returing the prev/next ids which are not
in alpha order.

$this->Game->find('neighbors',array
('fields'=>'Game.title','order'=>'Game.title ASC'));

Thanks!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Add/Insert data into two tables

2009-05-08 Thread mklappen

I have the following function set up in my GenresController. This
function is called when a user is viewing a Game and wants to add a
new genre to the DB and associate it with the game currently being
viewed.

The Game and Genre models share a HABTM relationship...I'm not having
any problems adding new genre into the Genres table, however I can't
figure out how to also add it into the HABTM relationship table
(gamesgenres).

Models:
Games
Genres
GamesGenres

Do I need to create a controller/model for the gamesgenres table and
then pass it $this->data and $id? ($id is the game ID).

function addGenreToGame ($id = null) {
  if (!empty($this->data)) {
   $this->Genre->create();
   if ($this->Genre->save($this->data)) {
/*the new genre is saved in genres table - but also want it to
insert the genre id and game id (which is from $id) into the
gamesgenres HABTM relationship table. */
$this->data['g
$this->redirect(array('controller' => 'games', 'action' => 'view/'.
$id));

   } else {

   }
  }
  $this->set('genredata', $this->Genre->Game->find());
  $this->render(addGenreToGame ,'ajax');
 }

Thanks for the help!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Help with Ajax form and CSS Styling

2009-04-14 Thread mklappen

Hi
I'm having some trouble with a form that I have styled in my CSS but
when it's loaded from an Ajax call it's not picking up the CSS styles

view.ctp:
used for viewing entries in my DB, I have "edit" links that link to
specific actions in my contoller that allows users to update/edit DB
entries.

>From view.ctp:

Genre


/*This div contains an "edit" link. Users can click edit and the
edit_genre action will be called and displays the edit_genre.ctp in
the "genreform" div listed below.*/

link('Edit Genre', 'edit_genre/'.$movie['Movie']
['id'], array('update' => 'genreform'));?>



//this section lists out the current "genre" entries in the DB for a
particular movie.


/* Problem Area
code from edit_genre.ctp will go here when user clicks "Edit Genre"
CSS Styling does not appear when user clicks edit and code is pulled
from edit_genre.ctp. However if I manually place form code here the
styling is picked up. */



from edit_genre.ctp: This code is inserted into view.ctp "genreform"
div when user clicks "Edit Genre"

create('Movie');?>


input('id');
echo $form->input('Genre', array( 'type' => 'select', 
'multiple' =>
'checkbox' ));
?>

end('Submit');?>


Thanks in advance for any advice.

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help using special character « in paginator

2009-03-15 Thread mklappen

thanks! working now :)

On Mar 14, 12:24 pm, brian  wrote:
> Add 'escape' => false to your params array.
>
> On Sat, Mar 14, 2009 at 12:45 PM, mklappen  wrote:
>
> > Hi
>
> > Is there a way to use the special characters « and » in
> > pagination class without cakephp converting the & sign into '&'?
>
> > I found  a couple posts on it here but they really haven't helped me
> > figure out if/how it can be done...
> >http://groups.google.com/group/cake-php/browse_thread/thread/a1963f64...
>
> > This is the code that was created from bake (I changed the << >> to
> > the html special char codes...)
>
> > prev('« '.__('previous', true), array(),
> > null, array('class'=>'disabled'));?>
> >  |      numbers();?>
> >  |      next(__('next', true).' »', array(),
> > null, array('class'=>'disabled'));?>
>
> > Thanks in advance for any help.

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Help using special character « in paginator

2009-03-14 Thread mklappen

Hi

Is there a way to use the special characters « and » in
pagination class without cakephp converting the & sign into '&'?

I found  a couple posts on it here but they really haven't helped me
figure out if/how it can be done...
http://groups.google.com/group/cake-php/browse_thread/thread/a1963f6414213afc/0c05bc1d544faecc?lnk=gst&q=html+character+code#0c05bc1d544faecc

This is the code that was created from bake (I changed the << >> to
the html special char codes...)

prev('« '.__('previous', true), array(),
null, array('class'=>'disabled'));?>
 |  numbers();?>
 |  next(__('next', true).' »', array(),
null, array('class'=>'disabled'));?>

Thanks in advance for any help.

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can you have multiple hasAndBelongsToMany relationships in one model?

2009-02-16 Thread mklappen

Thanks... I did try that but must have made a typo somewhere because
it didn't work when I did.

got it all working.

Thanks again.

On Feb 16, 6:00 pm, "Adam Royle"  wrote:
> var $hasAndBelongsToMany = array('Developer','Publisher');
>
> ----- Original Message -
> From: "mklappen" 
> To: "CakePHP" 
> Sent: Tuesday, February 17, 2009 9:24 AM
> Subject: Can you have multiple hasAndBelongsToMany relationships in one
>
> model?
>
> > Hi,
>
> > I'm new to cake and this group, I would like to know if it is possible
> > to add multiple hasAndBelongsToMany relationships in one model? ( I
> > assume it is...)
>
> > my declaration & first instance of it is working fine, however it's
> > not letting me add another...
> > example:
> >  > class Game extends AppModel {
> > var $name = 'Game';
> > var $hasAndBelongsToMany = array('Developer');
> > //want to add second many to many relationship here.
>
> > $hasAndBelongsToMany = array('Publisher'); //does not work... tried
> > other syntax as well w/ no luck.
> > }
> > ?>
>
> > Thanks in advance.
> > mk

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Can you have multiple hasAndBelongsToMany relationships in one model?

2009-02-16 Thread mklappen

Hi,

I'm new to cake and this group, I would like to know if it is possible
to add multiple hasAndBelongsToMany relationships in one model? ( I
assume it is...)

my declaration & first instance of it is working fine, however it's
not letting me add another...
example:


Thanks in advance.
mk

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---