Skip to main content
Post Closed as "Needs details or clarity" by leymannx, No Sssweat, Alfred Armstrong, mradcliffe, Felix Eve
deleted 93 characters in body; edited title
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Programatically Programmatically render a view as htmlHTML

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

        $('.view-all-content').click(function () {

  $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function (data) {

                console.log(data)
             
    // if (data == "gg") {
 
                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

     });

});

In my function.php

function get_data_from_view() {

  $view = \Drupal::service('renderer')->render(views_embed_view('article_list', }'page_5'));

  // Other code ...

  echo $view;
});

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5'));

//Also i have added foreach

echo $view;

}

Programatically render view as html

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {
 
                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5'));

//Also i have added foreach

echo $view;

}

Programmatically render a view as HTML

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function () {

  $.post("/callajax", {
    'action': 'get_data_from_view',

  }, function (data) {

    console.log(data)
     
    // if (data == "gg") {
    //    console.log("suc")
    // }

    $(".view-all-content-result").html(data);

  });

});

In my function.php

function get_data_from_view() {

  $view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5'));

  // Other code ...

  echo $view;
}
added 512 characters in body
Source Link
salu
  • 119
  • 1
  • 14

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {

                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5'));   

//Also i have added foreach echo $data;

echo $view;

}

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {

                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5'));  //Also i have added foreach echo $data;

}

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {

                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5')); 

//Also i have added foreach

echo $view;

}

added 512 characters in body
Source Link
salu
  • 119
  • 1
  • 14

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {

                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5')); //Also i have added foreach echo $data;

}

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

I am using a custom function. In a button click i want to display view page. Here i want to render my view programatically in html format. How can i do that?

This is my jquery code:

$('.view-all-content').click(function() {

            $.post("/callajax", {
                'action': 'get_data_from_view',
                
            }, function(data) {

                console.log(data)
                // if (data == "gg") {

                //    console.log("suc")
                // }

                $(".view-all-content-result").html(data);

            });

        });

In my function.php

function get_data_from_view(){

$view = \Drupal::service('renderer')->render(views_embed_view('article_list', 'page_5')); //Also i have added foreach echo $data;

}

syntax errors
Source Link
GiorgosK
  • 8.5k
  • 1
  • 42
  • 55
Loading
Source Link
salu
  • 119
  • 1
  • 14
Loading