Correct MVC in CodeIgniterCodeigniter Model OptimizationAm I using MVC Codeigniter correctly?A good example...

Cryptic with missing capitals

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

Parsing a string of key-value pairs as a dictionary

What is this metal M-shaped device for?

Placing an adverb between a verb and an object?

Jumping Numbers

How do you funnel food off a cutting board?

Is there any differences between "Gucken" and "Schauen"?

Does fast page mode apply to ROM?

Using only 1s, make 29 with the minimum number of digits

Isn't using the Extrusion Multiplier like cheating?

What is the wife of a henpecked husband called?

Can you earn endless XP using a Flameskull and its self-revival feature?

How to deal with an incendiary email that was recalled

Groups acting on trees

Compress command output by piping to bzip2

What's the most convenient time of year to end the world?

Grade 10 Analytic Geometry Question 23- Incredibly hard

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Strange Sign on Lab Door

Why did other German political parties disband so fast when Hitler was appointed chancellor?

What to do if authors don't respond to my serious concerns about their paper?

Citing paywalled articles accessed via illegal web sharing



Correct MVC in CodeIgniter


Codeigniter Model OptimizationAm I using MVC Codeigniter correctly?A good example of codeigniter MVC?Codeigniter Registration ControllerCodeigniter view within a viewDynamic routing with lazy load controllersRedirecting to a fileImplementation of MVC Bootstrap & FactoryPermission control on CodeigniterPHP function which filters content from Wordpress database (wp_posts table)













2












$begingroup$


In my CodeIgniter project I have a Login controller that load this view:



<ul class="sub-menu">
<li>
<a href="javascript:;" class = "menu-item" data-target="../indoamericana/soporte/callSupport/"> Mis solicitudes </a>
</li>
</ul>


The controller: soporte, function: callSupport



public function callSupport($index = null, $order = null){
$session_data = $this->session->userdata('session_user');
$data['solicitud'] = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order);
$data['categories'] = $this->helpdesk_model->getCategories();
$this->load->view('modules/help_desk/supports', $data);
}


With jQuery I call the controller and render in a page content that is a <div> element:



$(".sub-menu .menu-item, .module-item").click(function(event) {
$(".page-content").load($(this).data('target'));
$("title").text( $( this ).text() );
});


In the view 'modules/help_desk/supports':



<table class="table table-striped table-hover" id="admin-support" data-target="soporte/callSupport/"> 
<thead>
<tr>
<th>Estado <a href="javascript:;"><i class="icon-sort" data-sort="status"></i></a></th>
<th>Prioridad <a href="javascript:;"><i class="icon-sort" data-sort="priority"></i></a></th>
<th>Responsable <a href="javascript:;"><i class="icon-sort" data-sort="id_responsible"></i></a></th>
</tr>
</thead>
<tbody>
<?php foreach ($solicitud as $key => $value) { ?>
<tr>
<td><span class="label label-sm <?= $value['label']?> "><?= ucfirst($value['status']) ?></span></td>
<td><span class="badge <?= $value['class']?> "><?= $value['priority'] ?></span></td>
<td><?= $value['name'].' '.$value['last_name'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>


As you can see, in the first <td> a put an anchor tag calls another controller with jQuery similar than before. Please be critical, very severe with me.










share|improve this question











$endgroup$












  • $begingroup$
    If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
    $endgroup$
    – Roland Illig
    3 hours ago
















2












$begingroup$


In my CodeIgniter project I have a Login controller that load this view:



<ul class="sub-menu">
<li>
<a href="javascript:;" class = "menu-item" data-target="../indoamericana/soporte/callSupport/"> Mis solicitudes </a>
</li>
</ul>


The controller: soporte, function: callSupport



public function callSupport($index = null, $order = null){
$session_data = $this->session->userdata('session_user');
$data['solicitud'] = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order);
$data['categories'] = $this->helpdesk_model->getCategories();
$this->load->view('modules/help_desk/supports', $data);
}


With jQuery I call the controller and render in a page content that is a <div> element:



$(".sub-menu .menu-item, .module-item").click(function(event) {
$(".page-content").load($(this).data('target'));
$("title").text( $( this ).text() );
});


In the view 'modules/help_desk/supports':



<table class="table table-striped table-hover" id="admin-support" data-target="soporte/callSupport/"> 
<thead>
<tr>
<th>Estado <a href="javascript:;"><i class="icon-sort" data-sort="status"></i></a></th>
<th>Prioridad <a href="javascript:;"><i class="icon-sort" data-sort="priority"></i></a></th>
<th>Responsable <a href="javascript:;"><i class="icon-sort" data-sort="id_responsible"></i></a></th>
</tr>
</thead>
<tbody>
<?php foreach ($solicitud as $key => $value) { ?>
<tr>
<td><span class="label label-sm <?= $value['label']?> "><?= ucfirst($value['status']) ?></span></td>
<td><span class="badge <?= $value['class']?> "><?= $value['priority'] ?></span></td>
<td><?= $value['name'].' '.$value['last_name'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>


As you can see, in the first <td> a put an anchor tag calls another controller with jQuery similar than before. Please be critical, very severe with me.










share|improve this question











$endgroup$












  • $begingroup$
    If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
    $endgroup$
    – Roland Illig
    3 hours ago














2












2








2





$begingroup$


In my CodeIgniter project I have a Login controller that load this view:



<ul class="sub-menu">
<li>
<a href="javascript:;" class = "menu-item" data-target="../indoamericana/soporte/callSupport/"> Mis solicitudes </a>
</li>
</ul>


The controller: soporte, function: callSupport



public function callSupport($index = null, $order = null){
$session_data = $this->session->userdata('session_user');
$data['solicitud'] = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order);
$data['categories'] = $this->helpdesk_model->getCategories();
$this->load->view('modules/help_desk/supports', $data);
}


With jQuery I call the controller and render in a page content that is a <div> element:



$(".sub-menu .menu-item, .module-item").click(function(event) {
$(".page-content").load($(this).data('target'));
$("title").text( $( this ).text() );
});


In the view 'modules/help_desk/supports':



<table class="table table-striped table-hover" id="admin-support" data-target="soporte/callSupport/"> 
<thead>
<tr>
<th>Estado <a href="javascript:;"><i class="icon-sort" data-sort="status"></i></a></th>
<th>Prioridad <a href="javascript:;"><i class="icon-sort" data-sort="priority"></i></a></th>
<th>Responsable <a href="javascript:;"><i class="icon-sort" data-sort="id_responsible"></i></a></th>
</tr>
</thead>
<tbody>
<?php foreach ($solicitud as $key => $value) { ?>
<tr>
<td><span class="label label-sm <?= $value['label']?> "><?= ucfirst($value['status']) ?></span></td>
<td><span class="badge <?= $value['class']?> "><?= $value['priority'] ?></span></td>
<td><?= $value['name'].' '.$value['last_name'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>


As you can see, in the first <td> a put an anchor tag calls another controller with jQuery similar than before. Please be critical, very severe with me.










share|improve this question











$endgroup$




In my CodeIgniter project I have a Login controller that load this view:



<ul class="sub-menu">
<li>
<a href="javascript:;" class = "menu-item" data-target="../indoamericana/soporte/callSupport/"> Mis solicitudes </a>
</li>
</ul>


The controller: soporte, function: callSupport



public function callSupport($index = null, $order = null){
$session_data = $this->session->userdata('session_user');
$data['solicitud'] = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order);
$data['categories'] = $this->helpdesk_model->getCategories();
$this->load->view('modules/help_desk/supports', $data);
}


With jQuery I call the controller and render in a page content that is a <div> element:



$(".sub-menu .menu-item, .module-item").click(function(event) {
$(".page-content").load($(this).data('target'));
$("title").text( $( this ).text() );
});


In the view 'modules/help_desk/supports':



<table class="table table-striped table-hover" id="admin-support" data-target="soporte/callSupport/"> 
<thead>
<tr>
<th>Estado <a href="javascript:;"><i class="icon-sort" data-sort="status"></i></a></th>
<th>Prioridad <a href="javascript:;"><i class="icon-sort" data-sort="priority"></i></a></th>
<th>Responsable <a href="javascript:;"><i class="icon-sort" data-sort="id_responsible"></i></a></th>
</tr>
</thead>
<tbody>
<?php foreach ($solicitud as $key => $value) { ?>
<tr>
<td><span class="label label-sm <?= $value['label']?> "><?= ucfirst($value['status']) ?></span></td>
<td><span class="badge <?= $value['class']?> "><?= $value['priority'] ?></span></td>
<td><?= $value['name'].' '.$value['last_name'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>


As you can see, in the first <td> a put an anchor tag calls another controller with jQuery similar than before. Please be critical, very severe with me.







javascript php jquery html codeigniter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago









Sᴀᴍ Onᴇᴌᴀ

9,72262165




9,72262165










asked Jan 30 '14 at 16:03









AndreFontaineAndreFontaine

94411




94411












  • $begingroup$
    If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
    $endgroup$
    – Roland Illig
    3 hours ago


















  • $begingroup$
    If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
    $endgroup$
    – Roland Illig
    3 hours ago
















$begingroup$
If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
$endgroup$
– Roland Illig
3 hours ago




$begingroup$
If you are lucky, you'll never have a help desk employee called <script>alert(123)</script>. I wouldn't count on that, though. Better protect your code against cross-site scripting.
$endgroup$
– Roland Illig
3 hours ago










1 Answer
1






active

oldest

votes


















0












$begingroup$

I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the template parser class which should allow you to do this.




Please be critical, very severe with me.




Okay - I am not typically this critical but you wanted it.



Minor nitpicks



In the PHP code, $data is not declared before value are assigned to specific keys:




$data['solicitud']  = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order); 



I don't see a problem with this practice but the PHP documentation advises against it:




If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.






I tried running the jQuery callback through the demo page on eslint.org. Besides obvious things, it showed this warning:




'event' is defined but never used.




For this line:




$(".sub-menu .menu-item, .module-item").click(function(event) {



So while it is great that event is defined, it isn't needed.






share|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "196"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f40470%2fcorrect-mvc-in-codeigniter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the template parser class which should allow you to do this.




    Please be critical, very severe with me.




    Okay - I am not typically this critical but you wanted it.



    Minor nitpicks



    In the PHP code, $data is not declared before value are assigned to specific keys:




    $data['solicitud']  = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order); 



    I don't see a problem with this practice but the PHP documentation advises against it:




    If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.






    I tried running the jQuery callback through the demo page on eslint.org. Besides obvious things, it showed this warning:




    'event' is defined but never used.




    For this line:




    $(".sub-menu .menu-item, .module-item").click(function(event) {



    So while it is great that event is defined, it isn't needed.






    share|improve this answer









    $endgroup$


















      0












      $begingroup$

      I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the template parser class which should allow you to do this.




      Please be critical, very severe with me.




      Okay - I am not typically this critical but you wanted it.



      Minor nitpicks



      In the PHP code, $data is not declared before value are assigned to specific keys:




      $data['solicitud']  = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order); 



      I don't see a problem with this practice but the PHP documentation advises against it:




      If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.






      I tried running the jQuery callback through the demo page on eslint.org. Besides obvious things, it showed this warning:




      'event' is defined but never used.




      For this line:




      $(".sub-menu .menu-item, .module-item").click(function(event) {



      So while it is great that event is defined, it isn't needed.






      share|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the template parser class which should allow you to do this.




        Please be critical, very severe with me.




        Okay - I am not typically this critical but you wanted it.



        Minor nitpicks



        In the PHP code, $data is not declared before value are assigned to specific keys:




        $data['solicitud']  = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order); 



        I don't see a problem with this practice but the PHP documentation advises against it:




        If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.






        I tried running the jQuery callback through the demo page on eslint.org. Besides obvious things, it showed this warning:




        'event' is defined but never used.




        For this line:




        $(".sub-menu .menu-item, .module-item").click(function(event) {



        So while it is great that event is defined, it isn't needed.






        share|improve this answer









        $endgroup$



        I don't see much wrong with the code. The biggest concern I might have is that PHP code is mixed in with the HTML - an alternative to this would be using a template system. CodeIgniter has the template parser class which should allow you to do this.




        Please be critical, very severe with me.




        Okay - I am not typically this critical but you wanted it.



        Minor nitpicks



        In the PHP code, $data is not declared before value are assigned to specific keys:




        $data['solicitud']  = $this->helpdesk_model->getRequest($session_data['usuario'], $index, $order); 



        I don't see a problem with this practice but the PHP documentation advises against it:




        If $arr doesn't exist yet, it will be created, so this is also an alternative way to create an array. This practice is however discouraged because if $arr already contains some value (e.g. string from request variable) then this value will stay in the place and [] may actually stand for string access operator. It is always better to initialize a variable by a direct assignment.






        I tried running the jQuery callback through the demo page on eslint.org. Besides obvious things, it showed this warning:




        'event' is defined but never used.




        For this line:




        $(".sub-menu .menu-item, .module-item").click(function(event) {



        So while it is great that event is defined, it isn't needed.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        Sᴀᴍ OnᴇᴌᴀSᴀᴍ Onᴇᴌᴀ

        9,72262165




        9,72262165






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Code Review Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f40470%2fcorrect-mvc-in-codeigniter%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

            Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...