HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Is there any way to pull post content through from Vanilla in a sub directory to main html homepage

2

Comments

  • Is this the right thing you mean for an AJAX Request?
    function loadXMLDoc()
    {
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
    }
    xmlhttp.open("POST","demo_post.asp",true);
    xmlhttp.send();
    }

  • x00x00 MVP
    edited April 2015

    Is this the right thing you mean for an AJAX Request?

    jQuery tends to the abstract the various method used in ajax, so you don't have to worry about it. "Hand rolled" ajax can be a lot more fraught/complex to set up.

    grep is your friend.

  • Oh blimey, comments are appearing faster than I'm responding and trying things :p

    @hgtonight - I will look at this and see if I can work out how it's being done. Thank you.
    @x00 - I don't need much data at all, I simply want the body of the post (not whole body, just a snippet), the title of the post, the date and the name of the person who made the post.

  • ahughes3ahughes3 New
    edited April 2015

    Forgot to say, I have a styled format already for the content I want to pull through, which is as follows;

    <h4 class="classic-title"><span>Latest News</span></h4>
       <div class="latest-posts">
       <div class="call-action call-action-boxed-sidebar call-action-style1 no-descripton clearfix">
    
        <div class="latest-posts-classic custom-carousel touch-carousel" data-appeared-items="2">
          <!-- Posts 1 -->
          <div class="post-row item">
            <div class="left-meta-post">
              <div class="post-date"><span class="day">28</span><span class="month">Dec</span></div>
              <div class="post-type"><i class="fa fa-picture-o"></i></div>
            </div>
            <h3 class="post-title"><a href="#">Standard Post With Image</a></h3>
            <div class="post-content">
              <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit. <a class="read-more" href="#">Read More...</a></p>
            </div>
          </div>
    </div>
    </div>
    

    Not sure if that helps or just makes the whole thing more complicated. To be clear, I don't just want to display a list of posts, I would like to display the two latest posts as per the above. =)

  • @hgtonight - I can't test your work on jsfiddle can I? It needs to be on my live installation yes? Also, is this just going to show a list of posts, with no content?

  • x00x00 MVP
    edited April 2015

    If you you use Body you must put through strip_tags in php or var story = $(<div>'+body+'</div>).text(); in jQuery where body is the the raw Body data and story is the sanitised result. You can then use .substring to shorten.

    grep is your friend.

  • x00x00 MVP
    edited April 2015

    In hgtonight's case you don't have to worry about sanitation, you aren't getting raw data in JSON, instead you are getting a module view (HTML), which is pre-formatted.

    You can request any module in vanilla. Even make your own versiob, then requests it. This would save having to do much manipulation in javascript/jQuery.

    grep is your friend.

  • Hmm it appears the html code I posted in my previous post has rendered rather show as code. I couldn't find a code button to insert html. Am I missing it somewhere?

  • ~~~
    [code goes here]
    ~~~

    use three tilde and with three tilde

    grep is your friend.

  • x00x00 MVP
    edited April 2015

    @ahughes3 said:
    Forgot to say, I have a styled format already for the content I want to pull through, which is as follows;

    <h4 class="classic-title"><span>Latest News</span></h4>
    <div class="latest-posts">
       <div class="call-action call-action-boxed-sidebar call-action-style1 no-descripton clearfix">
    
        <div class="latest-posts-classic custom-carousel touch-carousel" data-appeared-items="2">
          <!-- Posts 1 -->
          <div class="post-row item">
            <div class="left-meta-post">
              <div class="post-date"><span class="day">28</span><span class="month">Dec</span></div>
              <div class="post-type"><i class="fa fa-picture-o"></i></div>
            </div>
            <h3 class="post-title"><a href="#">Standard Post With Image</a></h3>
            <div class="post-content">
              <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit. <a class="read-more" href="#">Read More...</a></p>
             </div>
          </div>
       </div>
    </div>
    

    grep is your friend.

  • The module view could be modified easily. Just modify the PostList method in /plugins/LatestPostList/modules/class.latestpostlistmodule.php.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I think I mentioned that for it to work you need to run that code from your site. I had to basically tell my server that it is OK to accept scripting requests from other hosts, which is insecure.

    I haven't looked at @hgtonight but he's been doing this longer than I. Mine was designed more to use what's there. Believe his plugin does a better job at outputting the latest post.

  • @hgtonight said:
    I have attached some example code that should be relatively easy to follow. The key knowledge is:

    1. Latest Post List must be enabled on your Vanilla forum
    2. js/ajax.js contains the pertinent JS code
    3. This requires the request to be from the Same Origin

    So just to check I understand, am I adding these files to the JS and CSS folders in my TLD or in the forum directory. I'm assuming they go in the TLD folders but just want to check.

  • @hgtonight

    Below is the url to where my LatestPostList module resides. In the folder there is a .class file and a modules folder with, what looks like the same .class file in it. Should I be linking to the main plugins folder or the modules folder? At the moment I am getting the error message from the script and I'm sure its just a filepath thing.

    http://www.virginatlanticvirtual.co.uk/forum/plugins/LatestPostList

  • x00x00 MVP
    edited April 2015

    It is common to think that if you have an url scheme like /a/b/c there will be corresponding directory structure. This is not usually the case with modern framworks where urls are not indicative of physical file structure (directories), except for some static files. Also you don't want to provide direct access to just any script on the server.

    In vanilla everything goes through a single dispatcher.

    In order to load any module through the API

    http://www.virginatlanticvirtual.co.uk/forum//module/[modulename]

    e.g.

    http://www.virginatlanticvirtual.co.uk/forum//module/latestpostlistmodule

    grep is your friend.

  • You can modify the plugin in which case you may wish to rename it.

    grep is your friend.

  • @x00 said:
    It is common to think that if you have an url scheme like /a/b/c there will be corresponding directory structure. This is not usually the case with modern framworks where urls are not indicative of physical file structure (directories), except for some static files. Also you don't want to provide direct access to just any script on the server.

    In vanilla everything goes through a single dispatcher.

    In order to load any module through the API

    http://www.virginatlanticvirtual.co.uk/forum//module/[modulename]

    e.g.

    http://www.virginatlanticvirtual.co.uk/forum//module/latestpostlistmodule

    So are you saying that even though the filepaths you've listed above don't correlate to my actual directories they would still work? Just trying to get my head around it as I've always seen filepaths as literal. :o

  • @ahughes3 Yes. @x00 listed the right URL to use.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • So would that make the call line from the script, as below?

    $.get("//localhost/forum//module/latestpostlistmodule")

    because it still gives me the error :(

  • If url schemes were all literal every search result, or discussion would need a corresponding physical file.

    grep is your friend.

Sign In or Register to comment.