Jump to content
Larry Ullman's Book Forums

Edward

Members
  • Posts

    1115
  • Joined

  • Last visited

  • Days Won

    27

Everything posted by Edward

  1. Hello Jonathon, please check out my thread http://www.larryullman.com/forums/index.php?/topic/1491-my-project-diary/page-3 (POST #52) You need to setup a login system, basically by overriding the original login system Yii have started you off with. It means overriding UserIdentity and doing some work in the loginform.php which is in models. You do not need to add user_id to a session as it can be fetched by this: $this->user_id = Yii::app()->user->getId(); If you are adding attributes to a model its a simple as this public function actionCreate() { $uploaded = false; // Set the image upload directory $imageDirectory = Yii::getPathOfAlias('webroot.images.item'); // Set the image thumbnail upload directory $imageThumbnailDirectory = Yii::getPathOfAlias('webroot.images.item.thumbnail'); // Load models required for item listing form $modelItem = new Item('item-listing-form'); $modelImage = new Image; $modelShipping = new Shipping('item-listing-form'); $modelShippingHasService = new ShippingHasService('item-listing-form'); $modelLocalPickup = new LocalPickup('item-listing-form'); $modelReturns = new Returns('item-listing-form'); if(isset($_POST['Item'], $_POST['Image'], $_POST['Image'], $_POST['Shipping'], $_POST['ShippingHasService'], $_POST['LocalPickup'], $_POST['Returns'])) { $modelItem->attributes = $_POST['Item']; $modelImage->attributes = $_POST['Image']; $imageFile = CUploadedFile::getInstance($modelImage,'image'); $modelShipping->attributes = $_POST['Shipping']; $modelShippingHasService->attributes = $_POST['ShippingHasService']; $modelLocalPickup->attributes = $_POST['LocalPickup']; $modelReturns->attributes = $_POST['Returns']; $modelItem->validate(); $modelImage->validate(); $modelShipping->validate(); $modelShippingHasService->validate(); $modelLocalPickup->validate(); $modelReturns->validate(); $transaction = Yii::app()->db->beginTransaction(); if($modelItem->save()) { $modelImage->item_id = $modelItem->id; // Save image and also change the name of the image to the item id $imageFileName = $modelItem->id; $imageFile->saveAs($imageDirectory.DIRECTORY_SEPARATOR.$imageFileName); if($modelImage->save()) { $modelShipping->item_id = $modelItem->id; if($modelShipping->save()) { $modelShippingHasService->shipping_id = $modelShipping->id; if($modelShippingHasService->save()) { $modelLocalPickup->item_id = $modelItem->id; if($modelLocalPickup->save()) { $modelReturns->item_id = $modelItem->id; if($modelReturns->save()) { $transaction->commit(); $this->redirect(array('view','id'=>$modelItem->id)); } else $transaction->rollBack(); } else $transaction->rollBack(); } else $transaction->rollBack(); } else $transaction->rollBack(); } else $transaction->rollBack(); } else $transaction->rollBack(); } $this->render('create',array( 'modelItem'=>$modelItem, 'modelImage'=>$modelImage, 'uploaded' => $uploaded, 'modelReturns'=>$modelReturns, 'modelShipping'=>$modelShipping, 'modelShippingHasService'=>$modelShippingHasService, 'modelLocalPickup'=>$modelLocalPickup, )); } Please ignore my image upload stuff now, i have to come back to this later on and do it up with some nice js and php. But this is what i done. Exceptions i was going to add in a little later on i don't to make it too complicated when i am trying to figure things out. There are also about another 8 models i have to add to this form but i just want to get my site following if you know what i mean. I hope this will give you a rough idea of how this works until. This is the best i can do right now until i can see Larry's way of doing this, if he does stuff better i will change all my stuff.
  2. You would set the session variables in the controller or model if model related.
  3. Cannot thank you enough for what I have learned.
  4. Edward

    Twitter Bootstrap

    Twitter Bootstrap is like a "Html Lego", put it together correctly and you can make some wonderful things.
  5. This thread should be kept in relationsion to Jonathon's question, he mentioned my name here so i gave a short response. Unfortantely i am unable to help him with the question so i have left my response only. On this occasion I have found you to be quite irratating as you give me advise like i know nothing, i am sorry if this comes across as offensive but i was not asking questions about my project. If you see me asking questions on the forum feel free to help otherwise keep things related to the thread the same as i was told before.
  6. Thats what we all do works the same for other css frameworks to. Worry about your own project.
  7. I saw that extension before, but i decided just to code in the twitterbootstrap css manually and it all worked perfect. Waiting for the 3 version of bootstrap to come out. Twitter boostrap is good for the buttons and layout but it is lacking for good tables and shading. I will just work it in custom to my yii framework as i will have to override quite a bit of there css to get things 100%
  8. Okay you would be able to save the appropriate action getting the post submission response in the controller. Then save data to the relevant model.
  9. You could setup two model scenario rules so that only certain data was required or to be validated for each situation. Then load up relevant models in view. Really it depends on what you are doing, so explaining a little more detail would be nice.
  10. Why not put both of the queries into the model company in just one method then use a return array to return both values. Otherwise what you are doing is correct.
  11. Yeah keeping it in a css folder helps you organize things well, thanks
  12. Why don't you check out MAMP which is for Mac and see if there current release supports the array $a = [] intialization i suspect the latest version would do.
  13. Yeah if your relationships are correct between all three tables you can use the with statement from the user table to get access to the company one. Is this the same relationship like in the Yii Book page_has_file?
  14. It is okay to have the css in the same folder it could also be in a separate folder. Make sure you are including the css file in your template.html script in the head section. For example <style type="text/css" media="screen">@import "css/main.css";</style>
  15. If you have a intermediatery table for the many to many relationship, why don't you just put some data into the tables for testing. You can then use the relational active records queries with the with statement and simply use the print_r function to print out the object to see if you are getting the correct data inserted or returned.
  16. Well it depends on what the id of admin is, if admin had an id of 1 then something like this <div class="row buttons"> <?php if (Yii::app()->user->id !== 1) { // Render the button if admin is not logged in with user id 1 CHtml::submitButton('Submit to all', array('class' => 'button-send-v2', 'value' => '','name'=>'all')); } ?> <span class="go-back"> <span class="gray-text"> or </span> <?= CHtml::link('Cancel', $this->createAbsoluteUrl('forum/index'), array('class' => 'go-back')); ?> </span> </div>
  17. I found another way to handle this, better not to render individual links but give the link its message id, then when it is clicked on that particular link is generated on the fly. That saves having to generate possibly up to 1000 dynamic links at a time.
  18. I made a mistake 4 million dollars enough for two houses.
  19. Thanks but i will be scrapping this code it does not work best for what i have to do. For my particular site its best to save the entire links within the database otherwise its simple the site will run too slow.
  20. I tried making a relationship to a table holding my countries and the Yii relationships would not work. So for instance if you have a dropdown list of areas and you wanted birmingham the only way i could access it would be find the id of birmingham, then find items that were located in birmingham via the id. I still don't understand why Yii didn't work when i put an id like you did for area id in one table but could not use relational active record, i always got an error no matter how i configured it. I think this is a time we need to use query builder for a simple join.
  21. There could be between 30 - 50 of these dynamic inbox links, so that code above would be repeated for each particular case with a case statement. Hardcoding into the view is not really possible as its all dynamic info and then the view would be doing logic, i did try to push the render return array funnction into the model then load that up in the view but it seems like too much processing. Okay ill find a way to generate the links as particular actions are taken. I was thinking of creating a widget like dropdownlist for the views, because i need to make the links bold for unread messages and regular font for read.
×
×
  • Create New...