joostvanveen / build-a-cms-with-codeigniter Goto Github PK
View Code? Open in Web Editor NEWSource code for the Tutsplus course 'Build a CMS with Codeigniter'
Source code for the Tutsplus course 'Build a CMS with Codeigniter'
what is the admin password?
Good day, I know that it has been a while since you have given this course, but I would like to say that it is brilliant. Thank you for your efforts. That being said, I am getting a error 1364 each time I try to create a new page. I spent 2 days now going thought the code and I can figure it out. I have also compared with your source code and cant find the error. See below.
A Database Error Occurred
Error Number: 1364
Field 'order' doesn't have a default value
INSERT INTO pages
(title
, slug
, body
, parent_id
) VALUES ('yesy', 'test', 'uoshgushfg', 0)
Filename: C:\xampp\htdocs\onpoint_ci\system\database\DB_driver.php
Line Number: 330
I checked the page_m model and the page controller as well. The view is set correctly but i dont know where i went wrong. Your assistance would be greatly appreciated.
Thanks
The css urls lacked the public_html folder name.
I changed mine to
either of these are fine.
In function _class_open of generate.php controller
should be
also I found that swapping the last two
like so works better, but that's more of an opinion.
I just started last November. It's been quite an adventure so far. Thanks for the code and the great tutorials.
Hi sir, I have a problem with this code
`function get_menu($array, $child = FALSE)
{
$CI =& get_instance();
$str = '';
if (count($array)) {
$str .= $child == FALSE ? '<ul class="nav navbar-nav">'.PHP_EOL : '<ul class="dropdown-menu">'.PHP_EOL;
foreach ($array as $item) {
$active = $CI->uri->segment(1) == $item['slug'] ? TRUE : FALSE;
//Do we have any children?
if (isset($item['children']) && count($item['children'])) {
$str .= $active ? '<li class="dropdown active">' : '<li class="dropdown">';
$str .= '<a href="'.site_url(e($item['slug'])).'">'.e($item['title']);
$str .= ' <b class="caret"></b></a>'.PHP_EOL;
$str .= get_menu($item['children'], TRUE);
}
else {
$str .= $active ? '<li class="active">' : '<li>';
$str .= '<a href="'.site_url($item['slug']).'">'.e($item['title']).'</a>';
}
$str .= '</li>'.PHP_EOL;
}
$str .= '</ul>' . PHP_EOL;
}
return $str;
}`
When I enter the homepage, do not select the start menu as active, maybe it's because in my bd I have:
Table pages
id title slug order body parent_id
1 Homepage / 1 otro parrafo 0
I understand that when $active = $CI->uri->segment(1) == $item['slug'] ? TRUE : FALSE;
in the uri segment there is a string = $item['slug']
should be as active
but in this case.
How would I do to show me as active in the first menu, if when I enter the home page there is no string to make the comparison?
I'm sorry for bothering you, but I do not know how to solve this...
thanks.
Hi Sir.
I have a problem when I enter the page http://ci-cms.com/article/
An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function Article::index(), 0 passed in C:\xampp\htdocs\ci-cms\system\core\CodeIgniter.php on line 532 and exactly 2 expected
Filename: C:\xampp\htdocs\ci-cms\application\controllers\article.php
Line Number: 12
Backtrace:
File: C:\xampp\htdocs\ci-cms\index.php
Line: 320
Function: require_once
How can i resolve this problem?
Thanks.
There is a issue with the ordering of pages. If we put Homepage as a child of About or Contact and hit the save button 'homepage' will not show up after the save.
Similarly if we put homepage and contact as a child of about. Then again the homepage doesn't show up. Take a look at the screenshot below:
The above pages show the following order, homepage is missing. Is this a problem or I am not getting the concept behind ordering the pages?
Hi joostvanveen first of all I want to thank you for your very nice tutorial but I have faced a problem in your users controller that has an error when we edit a user an empty password get hashed and saved in database I have solved it by doing this
if($this->form_validation->run() == TRUE) {
//We can login and redirect user`
$data = $this->users_m->array_from_post(array('name', 'email', 'password'));
if(!empty($data['password'])) {
$data['password'] = $this->users_m->hash($data['password']);
} else {
unset($data['password']);
}
$this->users_m->save($data, $user_id);
redirect('admin/users','refresh');
}
Please tell me if this has any problems or any other best practice to do with this otherwise you have cleared so many things in this tutorial
hey i have being though your cms tuts and it works great locally but when upload it to hostgator the frontend works find but backend don't can you please help
Hi Sir, you're awesome teaching in this course, but I have a problem in the file page_m.php with the method get_nested(), when i have my records in phpmyadmin of this manner
id title .... parent_id
1 homepage ... 0
5 contact ... 6
6 about ... 0
in the method get_nested(), just back array only with parent_id=0, but not the children:
Dump => array(2) {
[1] => array(6) {
["id"] => string(1) "1"
["title"] => string(8) "Homepage"
["slug"] => string(1) "/"
["order"] => string(1) "1"
["body"] => string(241) "Multiple function calls can be made if you need several joins in one query.
If you need a specific type of JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer."
["parent_id"] => string(1) "0"
}
[6] => array(6) {
["id"] => string(1) "6"
["title"] => string(5) "about"
["slug"] => string(5) "about"
["order"] => NULL
["body"] => string(46) "
esta página about
"
["parent_id"] => string(1) "0"
}
}
but, If I change the order of my records in phpmyadmin
id title .... parent_id
1 homepage ... 0
5 contact ... 0
6 about ... 5
I get the children
Dump => array(2) {
[1] => array(6) {
["id"] => string(1) "1"
["title"] => string(8) "Homepage"
["slug"] => string(1) "/"
["order"] => string(1) "1"
["body"] => string(241) "Multiple function calls can be made if you need several joins in one query.
If you need a specific type of JOIN you can specify it via the third parameter of the function. Options are: left, right, outer, inner, left outer, and right outer."
["parent_id"] => string(1) "0"
}
[5] => array(7) {
["id"] => string(1) "5"
["title"] => string(7) "contact"
["slug"] => string(7) "contact"
["order"] => NULL
["body"] => string(36) "
nbuevo ontenido
"
["parent_id"] => string(1) "0"
["children"] => array(6) {
["id"] => string(1) "6"
["title"] => string(5) "about"
["slug"] => string(5) "about"
["order"] => NULL
["body"] => string(46) "
esta página about
"
["parent_id"] => string(1) "5"
}
}
}
How can I resolve this problem?
Regards.
i want to redirect slug that was incorrect but I am getting error with URL is not detected.
This is my controller:
public function index($id = null, $slug = ''){
// Fetch the article
$this->data['article'] = $this->mberita->get_by_id($id,$slug);
// Return 404 if not found
count($this->data['article']) || show_404(uri_string());
// Redirect if slug was incorrect
$requested_slug = $this->uri->segment(3);
$set_slug = $this->data['article']->slug;
if ($requested_slug != $set_slug) {
redirect('article/' . $this->data['article']->id . '/' . url_title($set_slug), 'location', '301');
// Load view
$this->data['contents'] = 'article';
$this->load->view('template/wrapper/mahasiswa/wrapper_article', $this->data);
}
view url
url become like this
index.php/article/77/kejurnas-mahasiswa
but URL is not detected. can you help me what to do.
Thank you.
Dear friend.
This is me, I want to do some changes in databases and adding 3 level of users
administrators, bloggers and joined readers. i am started it newly and i will have many problems firs of all is that in user controller of admin dashboard when I run this query :
$this->db->select('users.user_id,user_info.name,user_info.fam');
$this->db->from('users');
$this->db->join('user_info', 'users.user_id = user_info.user_id');
$data= $this->db->get();
var_dump($data);
the result is :
object(CI_DB_mysql_result)#15 (8) { ["conn_id"]=> resource(34) of type (mysql link) ["result_id"]=> resource(35) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(2) ["row_data"]=> NULL }
I will be appropriated if you help me to finish these changes.
kindly regards
That 3 Tables are:
CREATE TABLE IF NOT EXISTS user_type
(
user_type
int(4) NOT NULL AUTO_INCREMENT,
type_name
varchar(15) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (user_type
),
UNIQUE KEY user_type
(user_type
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=4 ;
INSERT INTO user_type
(user_type
, type_name
) VALUES
(1, 'Administrator'),
(2, 'Blogger'),
(3, 'User');
CREATE TABLE IF NOT EXISTS users
(
user_id
int(9) NOT NULL AUTO_INCREMENT,
email_add
varchar(35) COLLATE utf8_bin DEFAULT NULL,
password
varchar(128) COLLATE utf8_bin NOT NULL,
last_login
datetime NOT NULL,
usr_typ_id
int(4) DEFAULT NULL,
permissions
varchar(50) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (user_id
),
UNIQUE KEY email_add
(email_add
),
KEY fk_usr_typ_id
(usr_typ_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=92090005 ;
INSERT INTO users
(user_id
, email_add
, password
, last_login
, usr_typ_id
, permissions
) VALUES
(92090001, '[email protected]', '8389', '2014-01-03 22:45:02', 1, ''),
(92090002, '[email protected]', '9291', '2014-01-03 22:47:27', 2, ''),
(92090003, '[email protected]', '105229', '2014-01-03 22:47:27', 3, ''),
(92090004, '[email protected]', '1052', '2014-01-03 22:47:27', 1, '');
ALTER TABLE users
ADD CONSTRAINT fk_usr_typ_id
FOREIGN KEY (usr_typ_id
) REFERENCES user_type
(user_type
);
CREATE TABLE IF NOT EXISTS user_info
(
id
int(9) NOT NULL AUTO_INCREMENT,
user_id
int(9) DEFAULT NULL,
name
varchar(25) COLLATE utf8_bin NOT NULL,
fam
varchar(45) COLLATE utf8_bin NOT NULL,
cell
varchar(12) COLLATE utf8_bin NOT NULL,
company
varchar(45) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (id
),
UNIQUE KEY user_id
(user_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=100000003 ;
INSERT INTO user_info
(id
, user_id
, name
, fam
, cell
, company
) VALUES
(100000001, 92090001, 'hamed', 'salim', '09149306211', ''),
(100000002, 92090002, 'reza', 'salim', '09143711256', '');
ALTER TABLE user_info
ADD CONSTRAINT user_info_ibfk_1
FOREIGN KEY (user_id
) REFERENCES users
(User_id
);
if (!count($this->db->ar_orderby)) {
$this->db->order_by($this->_order_by);
}
The following code cannot be run in the progress. Please have a look. And if possible guide with a alternative since ar_orderby cannot be used anymore
Am new to codeigniter, and your video and really improve my knowledge on framework greatly, now i want to do more with the learnt concept, now i want to add image to the articles and also comment for each of the articles. please i await your solution. Thanks
Hi Friend;
thanks for your great teaching. I got this error when i finished course 12
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$parent_id
Filename: page/edit.php
Line Number: 7
page\edit line 7:
input->post('parent_id') ? $this->input->post('parent_id') : $page->parent_id); ?>i had to say i got a copy of your git and checked with what i have write from your courses. could you possibly help me to solve this?
I am working on this cms tutorials. and i also have that tutsplus video tutorials. I must say that you are great in all this.
I still have a problem with redirection from the validation form, so when i try to login using the good credentials, there is no error and i still be redirected to the admin/user/login. I tried to fix that but cant find any result.
Please help me in this issue . I am really stuck at this point and cant go ahead in this tutorial because of this login problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.