Click here to Skip to main content
15,851,701 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralRe: Posting an article without an email. Pin
PIEBALDconsult7-Aug-22 8:07
mvePIEBALDconsult7-Aug-22 8:07 
GeneralRe: Posting an article without an email. Pin
Chris Maunder7-Aug-22 10:35
cofounderChris Maunder7-Aug-22 10:35 
GeneralRe: Posting an article without an email. Pin
Member 150787168-Aug-22 4:34
Member 150787168-Aug-22 4:34 
QuestionHowto image clickable ? Pin
Patrice T31-Jul-22 21:51
mvePatrice T31-Jul-22 21:51 
AnswerRe: Howto image clickable ? Pin
Jo_vb.net2-Aug-22 13:57
mvaJo_vb.net2-Aug-22 13:57 
AnswerRe: Howto image clickable ? Pin
Sean Ewington8-Aug-22 4:49
staffSean Ewington8-Aug-22 4:49 
GeneralRe: Howto image clickable ? Pin
Patrice T8-Aug-22 6:16
mvePatrice T8-Aug-22 6:16 
Questioncode-igniter category wise article is not showing Pin
bharosewale29-Jul-22 11:42
bharosewale29-Jul-22 11:42 
I have created a home page in codeigniter and have created a home controller in it. Index method has been created in the home controller, in which all articles have been shown. Now another function is added in the home controller in which to show all articles of single category, I also made model but in this show all articles in all categories. If I am calling only method then query is working but showing in home html page then all data showing all category.please help me



view page

<?php $this->load->view('front/header'); ?>
        <div class="container pt-4 pb-4">
    				<h3 class="pb-3">About Company</h3>
    				<p class="text-muted"> Nike clearly knows its audience and makes their mission obvious to them as soon as they land on the About Us page. There's no question that the visitor is in the right place and understands exactly what Nike has set out to do. </p>
    				<p class="text-muted"> Nike clearly knows its audience and makes their mission obvious to them as soon as they land on the About Us page. There's no question that the visitor is in the right place and understands exactly what Nike has set out to do. </p>
				</div>
				<!--computer category list-->
				<?php if(!empty($articles)){?>
					<?php $this->load->view('front/computer_category');?>
				<?php }?>


<!--yoga news start-->
<?php if(!empty($articles)){?>
				<div class="pb-4 pt-4">
					<div class="container">
				<div class="row gx-4">
					<div class="p-3 border bg-success text-white">
	        				<h3>योग</h3>
	        			</div>
        			</div>
        			<div class="row pb-3 pt-4">
        				<?php foreach ($articles as $article) {?>
	        		<div class="col-md-3">
	        			<div class="card">
	        			 		<?php if(file_exists('./public/uploads/articles/thumb_admin/'.$article['image'])){?>
	    <img src="<?php echo base_url('public/uploads/articles/thumb_admin/'.$article['image'])?>" class="card-img-top" alt="">

	        			 		<?php }?>
	    						<div class="card-body">
	        						
	        						<p class="card-text"><?php echo $article['title'];?></p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
	        			<?php }?>
        	</div>
        	</div>
      	</div><!--latest blogs-->
      			<?php }?>


<!--yoga news end-->




<!--lifestyle news start-->
<?php $this->load->view('front/lifestyle');?>


<!--lifestyle news end-->


<!--technology news start-->
<?php if(!empty($articles)){?>
				<div class="pb-4 pt-4">
					<div class="container">
				<div class="row gx-4">
					<div class="p-3 border bg-success text-white">
	        				<h3>लाइफस्टाइल</h3>
	        			</div>
        			</div>
        			<div class="row pb-3 pt-4">
        				<?php foreach ($articles as $article) {?>
	        		<div class="col-md-3">
	        			<div class="card">
	        			 		<?php if(file_exists('./public/uploads/articles/thumb_admin/'.$article['image'])){?>
	    <img src="<?php echo base_url('public/uploads/articles/thumb_admin/'.$article['image'])?>" class="card-img-top" alt="">

	        			 		<?php }?>
	    						<div class="card-body">
	        						
	        						<p class="card-text"><?php echo $article['title'];?></p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
	        			<?php }?>
        	</div>
        	</div>
      	</div><!--latest blogs-->
      			<?php }?>


<!--technology news end-->








				<div class="bg-light pb-4">
					<div class="container">
        	<h3 class="pb-3 pt-4">OUR SERVICES</h3>
        	<div class="row">
	        		<div class="col-md-3">
	        			<div class="card"> 
	    						<img src="<?php echo base_url('public/images/box1.jpg');?>" class="card-img-top" alt="">
	    						<div class="card-body">
	        						<h5 class="card-title">Website Development</h5>
	        						<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->

	        		<div class="col-md-3">
	        			<div class="card"> 
	    						<img src="<?php echo base_url('public/images/box2.jpg');?>" class="card-img-top" alt="">
	    						<div class="card-body">
	        						<h5 class="card-title">Website Development</h5>
	        						<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->

	        		<div class="col-md-3">
	        			<div class="card"> 
	    						<img src="<?php echo base_url('public/images/box3.jpg');?>" class="card-img-top" alt="">
	    						<div class="card-body">
	        						<h5 class="card-title">Website Development</h5>
	        						<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->

	        		<div class="col-md-3">
	        			<div class="card"> 
	    						<img src="<?php echo base_url('public/images/box4.jpg');?>" class="card-img-top" alt="">
	    						<div class="card-body">
	        						<h5 class="card-title">Website Development</h5>
	        						<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
        	</div>
        </div>
				</div><!--our services-->

				<?php if(!empty($articles)){?>
				<div class="pb-4 pt-4">
					<div class="container">
        			<h3 class="pb-3 pt-4">LATEST BLOGS</h3>
        				
        			<div class="row">
        				<?php foreach ($articles as $article) {?>
	        		<div class="col-md-3">
	        			<div class="card">
	        			 		<?php if(file_exists('./public/uploads/articles/thumb_admin/'.$article['image'])){?>
	    <img src="<?php echo base_url('public/uploads/articles/thumb_admin/'.$article['image'])?>" class="card-img-top" alt="">

	        			 		<?php }?>
	    						<div class="card-body">
	        						
	        						<p class="card-text"><?php echo $article['title'];?></p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
	        			<?php }?>
	        		
        	</div>
        	</div>
      	</div><!--latest blogs-->
      			<?php }?>

      	<?php $this->load->view('front/footer'); ?>






Home controller page

<?php 
class Home extends CI_Controller{
	function index(){
		$this->load->model('Article_model');
		$param['offset']=4;
		$param['limit']=0;
		$articles=$this->Article_model->getArticlesFront($param);
		//echo "<pre>";
		//print_r($articles);
		//echo "
";
//exit;
$data['articles']=$articles;
$this->load->view('front/home',$data);

}



function computerCategory($category_id=43){

$this->load->model('Category_model');
$this->load->model('Article_model');
$this->load->helper('text');
$this->load->library('pagination');

$param['offset']=4;
$param['limit']=0;

$category=$this->Category_model->getCategory($category_id);


$articles=$this->Article_model->getComputerArticlesFront($param);

$data=[];


$data['articles']=$articles;

$data['category']=$category;

//$data['pagination_links']=$pagination_links;

#$this->load->view('front/blog',$data);
$this->load->view('front/computer_category',$data);
}



//function computerCategory(){
//$this->load->model('Category_model');
//$this->load->model('Article_model');
//$param['offset']=4;
//$param['limit']=0;
//$articles=$this->Article_model->getComputerArticlesFront($param);
//$data=[];
//$data['articles']=$articles;

//$this->load->view('front/computer_category',$data);
//echo "
";
		//print_r($articles);
		//echo "
";
//exit;
//}



//function lifestyleCategory(){
//$this->load->model('Article_model');
//$param['offset']=4;
//$param['limit']=0;
//$articles=$this->Article_model->getlifestyleArticlesFront($param);
//$data['articles']=$articles;
//$this->load->view('front/computer_category',$data);
//echo "
";
		//print_r($articles);
		//echo "
";
//exit;
//}

function lifestyleCategory($category_id=42){

$this->load->model('Category_model');
$this->load->model('Article_model');
$this->load->helper('text');
$this->load->library('pagination');

$param['offset']=4;
$param['limit']=0;

$category=$this->Category_model->getCategory($category_id);


$articles=$this->Article_model->getlifestyleArticlesFront($param);

$data=[];


$data['articles']=$articles;

$data['category']=$category;

//$data['pagination_links']=$pagination_links;

#$this->load->view('front/blog',$data);
$this->load->view('front/computer_category',$data);
}
}
?>


Article model
<?php  


class Article_model extends CI_Model{
	
	function getArticle($id){
			$this->db->select('articles.*,categories.name as category_name');
		 	$this->db->where('articles.id',$id);

		 	$this->db->join('categories','categories.id=articles.category','left');
		 	$query=$this->db->get('articles');

		 	$article=$query->row_array();
		 	return $article;


	}

	function getArticles($param= array()){
		$query = $this->db->get('articles');
		if(isset($param['offset']) && isset($param['limit'])){
			$this->db->limit($param['offset'],$param['limit']);
		}

		if(isset($param['q'])){
			$this->db->or_like('title',trim($param['q']));
			$this->db->or_like('author',trim($param['q']));
		}
		

		$query = $this->db->get('articles');
		#echo $this->db->last_query();

		$articles = $query->result_array();
		return $articles;
	}
	
    
    function getArticlesCount($param= array()){// this function is use for count total article
    	 if(isset($param['q'])){
			$this->db->or_like('title',trim($param['q']));
			$this->db->or_like('author',trim($param['q']));
		}

		if(isset($param['category_id'])){
			$this->db->where('category',$param['category_id']);
		}
		$count=$this->db->count_all_results('articles');
		return $count;
	}

	function addArticle($formArray){
		$this->db->insert('articles',$formArray);
		return $this->db->insert_id();
	}

	function updateArticle($id,$formArray){
		$this->db->where('id',$id);
		$this->db->update('articles',$formArray);
		
	}

	function deleteArticle($id){
		$this->db->where('id',$id);
		$this->db->delete('articles');
		
	}

	/*front methods*/
	function getArticlesFront($param= array()){
		//$query = $this->db->get('articles');
		if(isset($param['offset']) && isset($param['limit'])){
			$this->db->limit($param['offset'],$param['limit']);
		}

		if(isset($param['q'])){
			$this->db->or_like('title',trim($param['q']));
			$this->db->or_like('author',trim($param['q']));
		}

		if(isset($param['category_id'])){
			$this->db->where('category',$param['category_id']);
		}

		$this->db->select('articles.*,categories.name as category_name');

		$this->db->where('articles.status',1);
		
		$this->db->order_by('articles.created_at','DESC');


		$this->db->join('categories','categories.id=articles.category','left');

		$query = $this->db->get('articles');
		#echo $this->db->last_query();

		$articles = $query->result_array();
		//echo $this->db->last_query();

		return $articles;
	}



	/*front computer category methods*/
	function getComputerArticlesFront($param= array()){
		
		if(isset($param['offset']) && isset($param['limit'])){
			$this->db->limit($param['offset'],$param['limit']);
		}

		if(isset($param['q'])){
			$this->db->or_like('title',trim($param['q']));
			$this->db->or_like('author',trim($param['q']));
		}

		if(isset($param['category_id'])){
			$this->db->where('category',$param['category_id']);
		}

		$this->db->select('articles.*');

		$this->db->where('articles.category',43);
		
		$this->db->order_by('articles.created_at','DESC');


		//$this->db->join('categories','categories.id=articles.category','left');
		$query = $this->db->get('articles');

		$articles = $query->result_array();

		return $articles;
	}
	



	/*front lifestyle category methods*/
	function getlifestyleArticlesFront($param= array()){
		//$query = $this->db->get('articles');
		if(isset($param['offset']) && isset($param['limit'])){
			$this->db->limit($param['offset'],$param['limit']);
		}

		if(isset($param['q'])){
			$this->db->or_like('title',trim($param['q']));
			$this->db->or_like('author',trim($param['q']));
		}

		if(isset($param['category_id'])){
			$this->db->where('category',$param['category_id']);
		}

		$this->db->select('articles.*,categories.name as category_name');

		$this->db->where('articles.category',42);
		
		$this->db->order_by('articles.created_at','DESC');


		$this->db->join('categories','categories.id=articles.category','left');

		$query = $this->db->get('articles');
		//echo $this->db->last_query();

		$articles = $query->result_array();
		//echo $this->db->last_query();

		return $articles;
	}
}
?>


computer_category view page

<!--computer news start-->
<?php if(!empty($articles)){?>
				<div class="pb-4 pt-4">
					<div class="container">
				<div class="row gx-4">
					<div class="p-3 border bg-success text-white">
	        				<h3>कंप्यूटर</h3>
	        			</div>
        			</div>
        			<div class="row pb-3 pt-4">
        				<?php foreach ($articles as $article) {?>
	        		<div class="col-md-3">
	        			<div class="card">
	        			 		<?php if(file_exists('./public/uploads/articles/thumb_admin/'.$article['image'])){?>
	    <img src="<?php echo base_url('public/uploads/articles/thumb_admin/'.$article['image'])?>" class="card-img-top" alt="">

	        			 		<?php }?>
	    						<div class="card-body">
	        						
	        						<p class="card-text"><?php echo $article['title'];?></p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
	        			<?php }?>
        	</div>
        	</div>
      	</div><!--latest blogs-->
      			<?php }?>


<!--computer news end-->

<!--lifestyle start-->
<?php if(!empty($articles)){?>
				<div class="pb-4 pt-4">
					<div class="container">
				<div class="row gx-4">
					<div class="p-3 border bg-success text-white">
	        				<h3>lifestyle</h3>
	        			</div>
        			</div>
        			<div class="row pb-3 pt-4">
        				<?php foreach ($articles as $article) {?>
	        		<div class="col-md-3">
	        			<div class="card">
	        			 		<?php if(file_exists('./public/uploads/articles/thumb_admin/'.$article['image'])){?>
	    <img src="<?php echo base_url('public/uploads/articles/thumb_admin/'.$article['image'])?>" class="card-img-top" alt="">

	        			 		<?php }?>
	    						<div class="card-body">
	        						
	        						<p class="card-text"><?php echo $article['title'];?></p>
	        						<a href="#" class="btn btn-primary">Go somewhere</a>
	    						</div>
								</div>
	        		</div><!--card 1-->
	        			<?php }?>
        	</div>
        	</div>
      	</div><!--latest blogs-->
      			<?php }?>

AnswerRe: code-igniter category wise article is not showing Pin
Richard Deeming1-Aug-22 1:34
mveRichard Deeming1-Aug-22 1:34 
QuestionHow to check submitted article status Pin
Member 1569523525-Jul-22 5:25
professionalMember 1569523525-Jul-22 5:25 
AnswerRe: How to check submitted article status Pin
Greg Utas25-Jul-22 5:59
professionalGreg Utas25-Jul-22 5:59 
QuestionI would like to live my published article Pin
Member 1570654314-Jul-22 4:26
Member 1570654314-Jul-22 4:26 
AnswerRe: I would like to live my published article Pin
Greg Utas14-Jul-22 5:06
professionalGreg Utas14-Jul-22 5:06 
GeneralRe: I would like to live my published article Pin
Pete O'Hanlon15-Jul-22 2:25
subeditorPete O'Hanlon15-Jul-22 2:25 
GeneralRe: I would like to live my published article Pin
Peter_in_278015-Jul-22 2:52
professionalPeter_in_278015-Jul-22 2:52 
QuestionCome posso cancellare la mia domanda per riformularla meglio? Pin
Member 1570281311-Jul-22 1:07
Member 1570281311-Jul-22 1:07 
AnswerRe: Come posso cancellare la mia domanda per riformularla meglio? Pin
OriginalGriff11-Jul-22 1:10
mveOriginalGriff11-Jul-22 1:10 
QuestionArticle section Pin
Stephane Capo22-Jun-22 22:19
professionalStephane Capo22-Jun-22 22:19 
AnswerRe: Article section Pin
Sean Ewington23-Jun-22 2:42
staffSean Ewington23-Jun-22 2:42 
GeneralRe: Article section Pin
Stephane Capo23-Jun-22 2:56
professionalStephane Capo23-Jun-22 2:56 
QuestionHow do I delete my question? Pin
ms36012-Jun-22 16:11
ms36012-Jun-22 16:11 
AnswerRe: How do I delete my question? Pin
Richard MacCutchan12-Jun-22 22:21
mveRichard MacCutchan12-Jun-22 22:21 
AnswerRe: How do I delete my question? Pin
Sean Ewington13-Jun-22 0:42
staffSean Ewington13-Jun-22 0:42 
QuestionArticle disappeared Pin
armagedescu7-Jun-22 4:19
armagedescu7-Jun-22 4:19 
AnswerRe: Article disappeared Pin
Sean Ewington7-Jun-22 4:32
staffSean Ewington7-Jun-22 4:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.