Yii Framework Forum: Beginner On Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Beginner On Yii Rate Topic: -----

#1 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 12 April 2014 - 08:25 AM

Hello,

Excuse me if my English is not good because i'm French ! ;)

So I'm new to Yii. I have to make a website for inventoring multiple network devices (basics fonctions like add an equipment, modify, delete). So I created my database with "phpmyadmin" which contains 3 tables. Using the Gii tool, I generated the codes of each of these tables, which create ​​3 files with the extension .php in the following path "C:\wamp\www\mysite\protected\models"..
I moved these 3 files in "C:\wamp\www\monsite". However, when I enter this path in Google Chrome, there is an error "Fatal error: Class 'CActiveRecord' not found in C:\wamp\www\mysite\Equipement.php on line 18".
How can I solve this problem please?

In addition, I saw on the site Yii an image (image enclose). It will suit perfectly for my project. How to make this type of table? Thank you very much.

Best regards,

Attached File(s)


0

#2 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 12 April 2014 - 08:36 AM

Bienvenue! If you're a new Yiier it's probably best to stick to the standard folder structure, i.e. the one created by the command yiic webapp <yourappname>. What you call "the code for these tables" are the models and they should be in the protected/models folder, not anywhere else. The specific error you're getting is probably due to your app not finding the Yii framework folder.

As for the table you saw it's called a CGridView and the Gii tool will generate it automatically when you move to the next step after model creation and generate the "CRUD" (create/retrieve/update/delete) scaffolding. Take a look at this section of The Guide.

Have fun!
José
0

#3 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 14 April 2014 - 12:51 AM

Hi ! Firstly I'm sorry for not be able to answer you earlier because I couldn't post more than 3 posts on my first day on this site.

Thank you for your help and your advise JFReyes ! I have finally decided to delete what I did and did it again properly. And it works ! I managed to obtain the table like on the image and the datas are well place in my database. :D So thank you !

But I still have some questions ! Is it possible to modify the login & password to connect to the page (admin/admin or demo/demo) and is it possible to custom the page like I would like please ? Thank you ! ;)

Then, I don't understand something ! When in Google Chrome, I write "localhost/monsite" there is a page call "My Web Application" which appears. But how can I for example access to my table "Equipment" without write in Google Chrome "localhost/monsite/index.php/Equipment" please ? For example, change the name of the tabs (Contact, About,...) ?
0

#4 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 14 April 2014 - 03:10 AM

To be more precise, when I write "localhost/monsite/index.php" and I'm on the tab "Home" I have the second image.

And if I wrote "localhost/monsite/equipement/index.php/equipement" I have the first image.

I dont't understand how can I access to "equipement" without written "localhost/monsite/index.php/equipement"

Attached File(s)

  • Attached File  1.PNG (11.2K)
    Number of downloads: 5
  • Attached File  2.PNG (21.29K)
    Number of downloads: 5

0

#5 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 14 April 2014 - 03:54 AM

I'm glad you're making headway...

1. Read what it says on the index (home) page because it's actually telling you where it's located so you can change its contents.

2. The menu is located at protected/views/layouts/main.php (also mentioned in the index page). You can set up a link for Equipement there.

3. The basic application doesn't use a user table so the allowed usernames and passwords have to be changed in protected/components/UserIdentity.php where they're hardcoded.

4. As for hiding index.php from the path, take a look at this section of the Guide.

Keep it up! :)
José
0

#6 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 14 April 2014 - 04:28 AM

View PostJFReyes, on 14 April 2014 - 03:54 AM, said:

I'm glad you're making headway...

1. Read what it says on the index (home) page because it's actually telling you where it's located so you can change its contents.

2. The menu is located at protected/views/layouts/main.php (also mentioned in the index page). You can set up a link for Equipement there.

3. The basic application doesn't use a user table so the allowed usernames and passwords have to be changed in protected/components/UserIdentity.php where they're hardcoded.

4. As for hiding index.php from the path, take a look at this section of the Guide.

Keep it up! :)


Thank you again JFReyes !

Yes I saw it on the page. But for example when I want to put an image on the page, there is the square but not the image (with a small draw like a broken image inside) although I put my image in this path "C:\wamp\www\siteregion\protected\views\site\index.php" then in this path "C:\wamp\www\siteregion\protected\views\layouts\main.php" ! And I can't modify the name of the tab in Google Chrome. It's still "My Web Applicatin" and I can't put an image.ico

Secondly, can you explain how set up a link please ? For the URL, which one must I give please ?
0

#7 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 14 April 2014 - 05:38 AM

1. The application name is in protected/config/main.php; that's where you configure different application parameters.

2. To display an image, place the file in the /images folder and use the CHtml::image() method; look it up in the Class Reference.

3. If the link is in the main menu, follow the examples already shown in protected/views/layouts/main.php. For a regular link use CHtml::link(), also explained in the Class Reference.
José
0

#8 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 14 April 2014 - 06:17 AM

View PostJFReyes, on 14 April 2014 - 05:38 AM, said:

1. The application name is in protected/config/main.php; that's where you configure different application parameters.

2. To display an image, place the file in the /images folder and use the CHtml::image() method; look it up in the Class Reference.

3. If the link is in the main menu, follow the examples already shown in protected/views/layouts/main.php. For a regular link use CHtml::link(), also explained in the Class Reference.

Thanky you !

For example, the file 'Equipment.php' that I have created with gii is in the path "C:\wamp\www\monsite\protected\models\Equipment.php" and I have created the CRUD model too. So what path must I have to put in main.php to have the tab "Equipment" please ?

I manage to display my image, but is is possible to display the image.ico in the tab ?
0

#9 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 14 April 2014 - 08:26 AM

To learn about routes (URL's) check the Guide's section on controllers. As for the icon, place the following in the <head> section of the main layout (at protected/views/layouts/main.php):

<link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/images/favicon.ico">

José
0

#10 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 14 April 2014 - 08:48 AM

View PostJFReyes, on 14 April 2014 - 08:26 AM, said:

To learn about routes (URL's) check the Guide's section on controllers. As for the icon, place the following in the <head> section of the main layout (at protected/views/layouts/main.php):

<link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/images/favicon.ico">



I will try as soon as possible ! Anyway, THANK YOU VERY MUCH JFReyes for your help ! ;)
0

#11 User is offline   Dimas Mahendra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 15-April 14

Posted 15 April 2014 - 01:02 AM

any know how to download guide yii?
0

#12 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 15 April 2014 - 02:08 AM

View PostDimas Mahendra, on 15 April 2014 - 01:02 AM, said:

any know how to download guide yii?


You can download what you want here "http://www.yiiframework.com/download/"
And if you want to download the folder Yii, in "Git Access" you click on "GitHub". And in the new page you click on "Download ZIP" on the right of the screen. Hope I answered you ! ;)
0

#13 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 15 April 2014 - 02:09 AM

JFReyes, I managed to find the good path ;)

Another important question for my project and I hope it's possible :( Do you know if it's possible to associate an image with an particular equipment. For example,I would like the equipment ID n°1 to be associate with "1.jpg", the ID n°2 with "2.jpg". And if I click on the equipment ID n°1, the page will show me the image associated with it ("1.jpg"). Is that possible to do something like that please ?

Another question, this morning I tried to apply my ".css" on my text ! But it doesn't work ! :(
I put my file "accueil.css" on the folder /css. And then in the file "index.php" I wrote

<link rel="stylesheet" type="text/css" href="/css/accueil.css" />
<div id="texte_logo">test</div>


And in "accueil.css" I wrote :

#texte_logo{ 
font-size:30;
font-family:MV Boli;
text-align:center;
color:#00bdf5;
}


Is it a problem of syntax or not the good method ? Thank you ! ;)
0

#14 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 15 April 2014 - 04:33 AM

There are a lot of image related how-to's in the Wiki as well as extensions; check them out.

As for the CSS, try the following:

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/apptemplate.css" />


By now you should have noticed that straight HTML links generally don't work unless they point outside your app, the reason being the app's folder hierarchy and the way Yii works. You should also have noticed that I have given you more links than straight answers; Yii is pretty well documented (Guide, Class Reference, Wiki, Extensions and forum) so I suggest you search first, not only to get answers faster but also to get ideas on how other folks do it. That's the way I learned it and it served me well.
José
0

#15 User is offline   OliSCF 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 12-April 14

Posted 15 April 2014 - 11:46 PM

Thank you JFReyes ! ;)
0

#16 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 508
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 16 April 2014 - 03:11 AM

De rien! :)
José
0

Share this topic:


Page 1 of 1
  • 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