Navigation

    APPDRAG Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular

    REMINDER

    Please be respectful of all AppDragers! Keep it really civil so that we can make the AppDrag community of builders as embracing, positive and inspiring as possible.

    can we fetch our blog posts with the searchbar discussed in the new docs?

    Cloud CMS (Pagebuilder, Blog, Shop, Newsletters, Code Editor)
    3
    18
    1284
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • David Alimi
      David Alimi @Linda MacDonald last edited by

      Hello @Linda-MacDonald,

      First of all, this is an example of what you receive from the API :
      alt text

      So we need to use "imageURL" and not 'image',
      Then, as you can see we will receive an incomplete link, so what you need to do is to add this below your variable let PublishDate :

                  let image = articles[i].imageUrl;
                  image = '//cf.appdrag.com/APPID/'+ image
      

      APPID : You can find the APPID of your project at the top right of your API function screen by clicking on 'Configure' :

      alt text

      Then, execute and you will see your images in your database 🙂 :

      alt text

      Don't hesitate if you've got other questions.
      Thanks & Have a nice day 🙂

      Linda MacDonald 1 Reply Last reply Reply Quote 1
      • Daniel Mulroy
        Daniel Mulroy last edited by

        @David-Alimi, very cool! Would have been perhaps simpler than what I did (client-side everything) and yes, much more helpful now that I see the second part of the tuto 🙂

        David Alimi 1 Reply Last reply Reply Quote 1
        • David Alimi
          David Alimi @Daniel Mulroy last edited by

          @Daniel-Mulroy 🙂

          1 Reply Last reply Reply Quote 0
          • Linda MacDonald
            Linda MacDonald @David Alimi last edited by

            @David-Alimi said in can we fetch our blog posts with the searchbar discussed in the new docs?:

            image = '//cf.appdrag.com/APPID/'+ image

            Hi again David thanks a mil for the tut, but I think I am messing up again 😕 so I changed image to image url and addec my appid and have saved and published my api key but my images are still not showing. Have doublechecked that my appid is correct and have pasted it where it say APPID in your example. do I need to change the 'image' column in my database as well? perhaps url or something?

            var request = require('request');
            var cloudbackend = require('appdrag-cloudbackend');
            cloudbackend.init(process.env.APIKEY, process.env.APPID);
            
            exports.handler = (event, context, callback) => {
            
                var options = {
                  'method': 'POST',
                  'url': 'https://api.appdrag.com/api.aspx',
                  'headers': {
                    'Content-Type': 'application/x-www-form-urlencoded'
                  },
                  form: {
                    'command': 'BlogArticlesList',
                    'appID': process.env.APPID,
                    'orderBy': 'publishDate'
                  }
                };
                request(options, async function (error, response) { 
                    var articles = JSON.parse(response.body).Table
                    
                    for (let i = 0; i < articles.length; i++) {
            
                        let title = articles[i].title ;
                        let description =  articles[i].description;
                        let category =  articles[i].category;
                        let author = articles[i].author;
                        let PublishDate = articles[i].PublishDate;
                        let image = articles[i].imageUrl;
                        image = '//cf.appdrag.com/APPID/'+ image
                        
                        var query = "INSERT INTO ArticlesBlog (title, description, image, category, author, PublishDate)";
                        query += "VALUES ('" + title + "', '" + description + "', '" + image + "','" + author + "','" + category + "', '"+ PublishDate +"')";
                        await cloudbackend.sqlExecuteRawQuery(query)
                    }
                    callback(null, 'OK')
                });
            }
            
            code_text
            
            1 Reply Last reply Reply Quote 0
            • Linda MacDonald
              Linda MacDonald last edited by

              @David-Alimi ok finally got it to work 🙂 but I could only get it to work after manually saving and publishing my api several times...so this is a manual process, i.e. I cannot get the blogposts to be saved automatically?

              Linda MacDonald 1 Reply Last reply Reply Quote 0
              • Daniel Mulroy
                Daniel Mulroy last edited by

                Hi Linda,

                You could try the "Schedule" option on the right side to have it run once per hour, day, etc. in order to keep current 🙂

                Linda MacDonald 1 Reply Last reply Reply Quote 2
                • Linda MacDonald
                  Linda MacDonald @Daniel Mulroy last edited by

                  @Daniel-Mulroy excellent idea 🙂 thanks a mil Daniel 🙂

                  1 Reply Last reply Reply Quote 1
                  • Linda MacDonald
                    Linda MacDonald @Linda MacDonald last edited by

                    @David-Alimi

                    so now to the search functionality. I noticed that you add the "what" word in your search example, but I don't have just one word I want to target. I want the title and a descriptioin. Does this mean that I have to copy and paste all titles and descriptions so that the search works on my blog posts?
                    thanks in advance
                    Linda

                    1 Reply Last reply Reply Quote 0
                    • David Alimi
                      David Alimi last edited by

                      Hi @Linda-MacDonald,

                      In our example, the user enters the word 'what' in the search bar and we search if it exists only in our titles (and our output is only the title of the article found).
                      However, you can also search if this word exists either in the title or in the description, and in this case you can select in the output ('title' and 'description')

                      If you want to search only in titles but want to receive the title + description, it's up to you to choose the output columns you want to receive.

                      Here is an example :

                      alt text

                      alt text

                      I hope I answer your question well.

                      Thank you and have a nice day

                      Linda MacDonald 1 Reply Last reply Reply Quote 0
                      • Linda MacDonald
                        Linda MacDonald @David Alimi last edited by

                        @David-Alimi thanks a mil 🙂 yes I would like to search in title, description and fetch the feature image...basically want to replicate the search in the ecommerce templates, it's really cool 🙂

                        David Alimi 1 Reply Last reply Reply Quote 1
                        • David Alimi
                          David Alimi @Linda MacDonald last edited by David Alimi

                          Hello @Linda-MacDonald,

                          I just modified the article to use the BLOG API with a search bar even more easily only in the front-end.

                          PS: No need to use the backend anymore 🙂
                          You can find the article here.

                          Linda MacDonald 1 Reply Last reply Reply Quote 0
                          • Linda MacDonald
                            Linda MacDonald @David Alimi last edited by

                            @David-Alimi fantastic 🙂
                            I have been obsessing about search for AGES!! 🙂 can we analyze our search-results somehow? if we use the database that is? I actually want to understand when people do not find what they are looking for, i.e. when they get 'result not found' and when they use a synonym which isn't in the blog post but would be the same topic. Is that level of analysis possible using appdrag only?

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post