Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Twitter button - dynamic tweet

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Twitter button - dynamic tweet

    I am trying to build a tweet button into my UX component with a dynamic message. Have very limited experience in html and javascript and hoping someone can advise. I want to dynamically control the anchor tag by building it to contain a desired message, in this case a match score at the time

    Please see this video clip showing the current behaviour. https://youtu.be/9UVb2IgTcU0

    Where the message reads ?Score Update? I would like to dynamically populate the values on the competing teams and the score e.g. Hamiltons vs Malmesbury Rugby Club - 50:0

    The tweet button is in an HTML free-form container.

    freeform container.jpg

    The html container contains a table and below the </table> tag is the code for the tweet button. (button code from twitter website - https://dev.twitter.com/web/tweet-button/parameters

    HTML Code:
    <table align="center" border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
    	<thead>
    		<tr>
    			<th scope="col" align="center" width="60%">&nbsp;</th>
    			<th scope="col" align="center" width="20%">Score</th>
    			<th scope="col" align="center" width="20%">Log Points</th>
    		</tr>
    	</thead>
    	<tbody>
    		<tr>
    			<td>{HomeClubName}</td>
    			<td align="center">{HomePoints}</td>
    			<td align="center">{LogPointsHome}</td>
    		</tr>
    		<tr>
    			<td>{AwayClubName}</td>
    			<td align="center">{AwayPoints}</td>
    			<td align="center">{LogPointsAway}</td>
    		</tr>
    	</tbody>
    </table>
    
    <a href="https://twitter.com/intent/tweet?button_hashtag=scrumIT_wp&text=Score%20Update%20"; target="_top" class="twitter-hashtag-button" data-size="large" data-related="scrumITsa">Tweet #scrumIT_wp</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    How can I dynamically change the anchor tag with my message. In other words change red part <a href="https://twitter.com/intent/tweet?button_hashtag=scrumIT_wp&text=Score%20Update%20" to Club A vs Club B - 10:0

    #2
    Re: Twitter button - dynamic tweet

    This may help get you a bit closer. It's not quite right though because it changes the Twitter "Intent" button to a regular tweet button. This is all a function of twitter so checking with them may help.

    Wrap your <a> tag in a div...

    Code:
    <div id="tweetBtn">
    <a href="https://twitter.com/intent/tweet?button_hashtag=scrumIT_wp&text=Score%20Update%20"; target="_top" class="twitter-hashtag-button" data-size="large" data-related="scrumITsa">Tweet #scrumIT_wp</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    </div>
    You'll need jQuery for this next part.

    Run this code from a button...

    Code:
    var score = encodeURIComponent('Club A vs Club B - 10:0');
    var url = "https://twitter.com/intent/tweet?button_hashtag=scrumIT_wp&text=" + score;
    jQuery("#tweetBtn").empty().append( '<a class="twitter-share-button" data-size="large" data-related="scrumITsa" href="' + url + '"> Tweet #scrumIT_wp</a>' );
    twttr.widgets.load();
    Basically you're replacing the rendered HTML Tweet code with your own... and then processing that HTML again.

    References:

    https://twittercommunity.com/t/issue...tton-url/56318

    http://stackoverflow.com/questions/1...51031#10551031

    https://dev.twitter.com/web/javascript/initialization

    Comment


      #3
      Re: Twitter button - dynamic tweet

      Thanks David. Works beautifully!
      https://youtu.be/wrAjmXuZOV0

      Comment


        #4
        Re: Twitter button - dynamic tweet

        That's excellent... could you post the code and html setup for it?

        Comment


          #5
          Re: Twitter button - dynamic tweet

          Here is a detailed explanation on how to create a tweet button on your web app.
          Twitter offers a tweet button generator that will help you generate a custom button. You can find the generator over here https://about.twitter.com/resources/buttons

          In my case I made use of the hashtag button
          Please watch this video for an explanation https://youtu.be/mYneQmXivzk

          This is the code required for the a5w page
          aa script tag in a5w page.jpg

          This is the empty div with id to populate in the html free-form layout
          HTML Code:
          <div id="tweetBtn"></div>
          This is the code in the javascript action dynamically generating the button and tweet
          Code:
          var field1= {dialog.object}.getValue('field1');
          var field2 = {dialog.object}.getValue('field2');
          
          
          var dynamicmessage= "My message, " + field1+ ", " + field2
          
          var finalmessage= encodeURIComponent(dynamicmessage);
          var url = "https://twitter.com/intent/tweet?button_hashtag=Yourhashtag&text=" + finalmessage;
          jQuery("#tweetBtn").empty().append( '<a class="twitter-hashtag-button" data-size="large" data-related="YourUserName" href="' + url + '"> Tweet #TestHashTag</a>' );
          twttr.widgets.load();

          Comment


            #6
            Re: Twitter button - dynamic tweet

            Jaco - bloody well done. Very generous of you to share this information. It never ceases to amaze me the things people get up to in Alpha purely driven by such endeavour. - Great Job.
            Insanity: doing the same thing over and over again and expecting different results.
            Albert Einstein, (attributed)
            US (German-born) physicist (1879 - 1955)

            Comment


              #7
              Re: Twitter button - dynamic tweet

              Cool, thanks for sharing with us Jaco
              Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

              Comment


                #8
                Re: Twitter button - dynamic tweet

                Thanks for posting that Jaco... appreciated. If you don't need to use an a5w page, you can include the the twitter function within the HTML Freeform control. Here it is, plus the function formatted a bit more... for readability.

                Code:
                <table align="center" border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
                	<thead>
                		<tr>
                			<th scope="col" align="center" width="60%">&nbsp;</th>
                			<th scope="col" align="center" width="20%">Score</th>
                			<th scope="col" align="center" width="20%">Log Points</th>
                		</tr>
                	</thead>
                	<tbody>
                		<tr>
                			<td></td>
                			<td align="center"></td>
                			<td align="center"></td>
                		</tr>
                		<tr>
                			<td></td>
                			<td align="center"></td>
                			<td align="center"></td>
                		</tr>
                	</tbody>
                </table>
                
                <div id="tweetBtn">
                <a href="https://twitter.com/intent/tweet?button_hashtag=scrumIT_wp&text=Score%20Update%20"; target="_top" class="twitter-hashtag-button" data-size="large" data-related="scrumITsa">Tweet #scrumIT_wp</a>
                </div>
                
                <script>
                !function(d,s,id){
                	var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
                	if(!d.getElementById(id)){
                		js=d.createElement(s);
                		js.id=id;
                		js.src=p+'://platform.twitter.com/widgets.js';
                		fjs.parentNode.insertBefore(js,fjs);
                	}
                }
                (document, 'script', 'twitter-wjs');
                </script>

                Comment


                  #9
                  Re: Twitter button - dynamic tweet

                  Thanks David. The reason I had to put the script in the a5w page was because I was getting an error re X-Frame security. I found some material online that the measure was put in place to avoid clickjacking. By no means an expert on this but thought I'd just put it out there if someone else gets the same error. By putting the <script> tag in the a5w page it resolved the matter for me.

                  For more on this read here http://javascript.info/tutorial/clickjacking

                  Comment


                    #10
                    Re: Twitter button - dynamic tweet

                    Yep... that's cool... understood. I was just showing more info.

                    Comment

                    Working...
                    X