A
A
Anton2014-08-31 15:21:37
JavaScript
Anton, 2014-08-31 15:21:37

How to "redirect" to another part of the template under another GET request in smarty?

Hello!
$action is taken from the php file, in which the value is passed to the template. $action itself is $_GET['action'];
The structure of my tpl file is like this:

{if $action eq 'html_tags' || $action eq 'html_attributes'}
    // Тут общий код для двух случаев $action.
    {if $action eq 'html_tags'}
        // Тут код для случая html_tags.
    {else}
        // Тут код для случая html_attributes.
    {/if}
{else}
    // Тут прочий код. Это не важно.
{/if}

I am currently on a page where $action = 'html_tags';
There is a link there, when clicked, I have to go to the part of the code where $action will be equal to 'html_attributes'.
--
I'm still weak in js, but I'll copy here the code with which I tried to achieve the result I needed. I know that I'm not using ajax get in the right way. I wrote here so that you could understand the idea itself. Here is the js code:
$('.link_attr').click(function(){
     var id = $(this).attr('title');
     $.ajax({
          type: 'GET',
          url: '/site/templates/templates.tpl',
          data: {'action' : 'html_attributes'},
          success: function(data){
                // Тут некоторые действия.
          }
     });
});

--
In short, I need to somehow change $_GET['action'] via ajax request without reloading the page. Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mx2000, 2014-09-01
@mx2000

but nothing that smarty is a server-side engine? A direct link to tpl will do nothing.
In general, it is likely that the HTML renderer for the $action eq 'html_tags' block lies in some HTML element - its content must be cleared by clicking on the link and the result of the server script execution must be added as innerHTML . Obviously, the script only needs to render a portion of the HTML from the entire template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question