Domanda

I need to add a simple rotator to the top of a friend's website. As the friend has NO tech/html knowledge and I don't want to be continually called to change the frequently changing content, I was hoping there was a plugin available that can use a simple text file to control the plugin?

What I have in mind is a simple "one item per line" layout such as:

image001.jpg, "This is the caption for image 1", sitepage.html
image002.jpg, "This is another caption and belongs to image 2", "/news/newsItem2.html"
...
and so on.

This way, my friend can simply upload the required pics, edit the file and upload it to the folder and reload the page. The plugin looks at the text file for the image name (which my friend has uploaded, hopefully!) and uses that, overlays the caption for the image and makes the whole thing a clickable link that goes to the URL specified. Obviously if it's a site page he's linking to, he'll need me to create the page first, but it might be that he's linking to an external page so he can control it entirely.

È stato utile?

Soluzione

I do not know if there is a plugin like that, but what you can try is something like:

$.ajax({
    url: "yourtextfile.txt",
    success : function(content)
    {
        var lines = content.split("\n");

        $.each(lines, function(key, line){
            // ---------------
            // TODO:  Do some splits to get the content
            // ---------------
            // Add the URL's and image to the slider content.
            $("#slider").append("<a href='" + splittedURL + "'><img src='" + splittedImgURL + "' /></a>");
        });
        // Initialize slider
        $("slider").slider();
    }
});

Now you are able to use whatever slider you like.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top