Removing Facebook and Twitter links from Course Summary page

Hi all, first post.

I have an Open edX Tutor deployment on a VM in a dedicated server. I am now trying to create a course, and see that on the Course Summary page there is a small panel/block under the image on the right side of the page (sorry, I’m new here, and so cannot post a screenshot), which has Facebook, Twitter and Email icons for sharing the course. I would like to remove the FB and Twitter icons, leaving solely the email sharing option.

I have removed the relevant blocks in the HTML in the following file, such that no SVG should be rendered, no links to Twitter and Facebook:

env/build/openedx/themes/indigo/lms/templates/courseware/course_about_sidebar_header.html

Unfortunately the panel persists in the Course Summary page. I have stopped and restarted tutor but no luck.

Any ideas would be greatly valued!

Hi @Xommon, welcome to the community!

Try overriding SOCIAL_SHARING_SETTINGS.

I think those might be for a different feature. If Xommon is talking about the below template, I don’t see any significant configuration options other than the ability to hide the entire block:

Thanks, that’s what I’ve done in fact, removing them entirely. However, the problem persists. Do I need to rebuild? This is a docker-compose deployment, wrapped by the excellent tutor tool.

Solved this with an image rebuild and restart of containers. Thanks all. I think I better understand how it’s all put together now.

It seems logical to me that this value course_about_show_social_links should be able to control if the block is applied or not, but I haven’t been able to figure out a way to apply it with a patch/plugin, doesn’t seem to render any change no matter where I put the patch.

Insofar as I can tell this isn’t an indigo-specific flag as it’s also in the core edx-platform here: Code search results · GitHub

There is a TODO note here that implies it was considered but not implemented:

    ## TODO: this should probably be an overrideable block,
    ##       or something allowing themes to do whatever they
    ##       want here (and on this whole page, really).

EDIT: Nevermind, I managed to figure it out, I was trying in the wrong places all this time. It’s not influenced by the plugin system, this value is set in the Django site configuration menu: Home › Site_Configuration › Site configurations › <SiteConfiguration: lms.domain.tld >
example:

{
    "ENABLE_PROFILE_MICROFRONTEND": "true",
    "COURSE_CATALOG_API_URL": "https://discovery.lms.domain.tld/api/v1",
    "course_about_show_social_links": false #<-- add this line
}

So, no need to manually modify templates after all :slight_smile:

Yeah, I think the TODO is more for the ability to replace the entire contents of the block, rather than just show/hide it.

Hi Joel!
I tried adding the social_links site configuration. It now looks like this:

{
    "ENABLE_PROFILE_MICROFRONTEND": "true", #<-- I already had this
    "course_about_show_social_links": "false" #<-- I added this
}

But social sharing icons are still visible on about-page (olive. Tutor v. 15.3.6). Does this config require a image build? Or is there something else I am missing?

Hi @GabiH
I’m not 100% certain but I think it might be due to the interpretation as either a string (“false”) or boolean (false)
In my testing it seems to work without quotes, so "course_about_show_social_links": false and it takes effect immediately with no rebuilding.

Doesn’t look like I can spot any major differences in this code/template between v15 and v19 so I expect this should work for you too
Hope this helps :slight_smile:

@Tim_McCormack I have a proposed modification to the template for consideration, which may at least partially fulfil that pending TODO notes, though if it’s implemented then my guess is it should be merged into both the tutor-indigo repo and the edx-platform for consistency.
I’ve only tested this my side on the indigo theme and not the base repo files, so while it works for me there may be other considerations I’m not aware of, so take this with a grain of salt and some extra scrutiny of course, but maybe this helps to give users some finer granular control.

In here I’ve expanded upon the variable course_about_show_social_links so the original variable can still be used to to create a complete override of social links, but if users want granular control of which socials to show they can also set:

"course_about_show_social_links_twitter": true/false
"course_about_show_social_links_facebook": true/false
"course_about_show_social_links_email": true/false

example, to set ONLY the email to be visible you can set the following site configuration: (applying true values is optional because they’re defaulted to true in the template if the config is not present, i just added for illustrative purposes)

{
    "ENABLE_PROFILE_MICROFRONTEND": "true",
    "course_about_show_social_links": true, <-- leaves the block active
    "course_about_show_social_links_facebook": false,  <-- disables facebook
    "course_about_show_social_links_twitter": false,  <-- disables twitter
    "course_about_show_social_links_email": true  <-- leaves only email icon available
}

Here I’ve now only got email links:

modified version of course_about_sidebar_header.html :

<%page expression_filter="h"/>
<%namespace name='static' file='../static_content.html'/>
<%!
import six

from django.utils.translation import gettext as _
from django.urls import reverse
from django.conf import settings
%>

<header>
  % if static.get_value('course_about_show_social_links', True):
  <div class="social-sharing">
    <div class="sharing-message">${_("Share with friends and family!")}</div>
    ## TODO: this should probably be an overrideable block,
    ##       or something allowing themes to do whatever they
    ##       want here (and on this whole page, really).
      <%
        site_domain = static.get_value('site_domain', settings.SITE_NAME)
        site_protocol = 'https' if settings.HTTPS == 'on' else 'http'
        platform_name = static.get_platform_name()
        course_path = reverse('about_course', args=[str(course.id)])
        course_url = f"{site_protocol}://{site_domain}{course_path}"

        ## Translators: This text will be automatically posted to the student's
        ## Twitter account. {url} should appear at the end of the text.
        tweet_text = _("I just enrolled in {number} {title} through {account} {url}").format(
            number=course.number,
            title=course.display_name_with_default,
            account=static.get_value('course_about_twitter_account', settings.PLATFORM_TWITTER_ACCOUNT),
            url=course_url
        )

        tweet_action = u"https://twitter.com/intent/tweet?text={tweet_text}".format(tweet_text=six.moves.urllib.parse.quote(tweet_text))

        facebook_link = f"https://www.facebook.com/sharer/sharer.php?u={six.moves.urllib.parse.quote(course_url)}"

        email_body = _("I just enrolled in {number} {title} through {platform} {url}").format(
                number=course.number,
                title=course.display_name_with_default,
                platform=platform_name,
                url=course_url
        )

        email_subject = _("Take a course with {platform} online").format(platform=platform_name)
        email_link = u"mailto:?subject={subject}&body={body}".format(
            subject=six.moves.urllib.parse.quote(email_subject.encode('UTF-8')),
            body=six.moves.urllib.parse.quote(email_body.encode('UTF-8'))
        )
      %>
      <!-- NEW IN INDIGO socialnetworks is improved with better SVGs icons -->
    % if static.get_value('course_about_show_social_links_twitter', True):
      <a href="${tweet_action}" class="share">
        <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
          <path d="M13.682 1.6875H16.1641L10.743 7.88203L17.1203 16.3125H12.1281L8.21523 11.2008L3.74336 16.3125H1.25781L7.05508 9.68555L0.941406 1.6875H6.06016L9.59336 6.35977L13.682 1.6875ZM12.8102 14.8289H14.1848L5.31133 3.09375H3.83477L12.8102 14.8289Z" fill="#9CA3AF"/>
          </svg><span class="sr">${_("Tweet that you've enrolled in this course")}</span>
      </a>
    % endif

    % if static.get_value('course_about_show_social_links_facebook', True):
      <a href="${facebook_link}" class="share">
        <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
          <path fill-rule="evenodd" clip-rule="evenodd" d="M18 9.05524C18 4.05403 13.9707 6.29184e-07 9 4.05324e-07C4.0293 1.81463e-07 2.31733e-07 4.05403 5.17607e-07 9.05524C7.75944e-07 13.5747 3.2913 17.3209 7.5942 18L7.5942 11.6731L5.3082 11.6731L5.3082 9.05524L7.5942 9.05524L7.5942 7.06037C7.5942 4.79113 8.937 3.53788 10.9935 3.53788C11.9781 3.53788 13.0077 3.71446 13.0077 3.71446L13.0077 5.94205L11.8737 5.94205C10.755 5.94205 10.4067 6.6402 10.4067 7.35647L10.4067 9.05524L12.9024 9.05524L12.5037 11.6722L10.4067 11.6722L10.4067 18C14.7087 17.3209 18 13.5747 18 9.05524Z" fill="#9CA3AF"/>
          </svg><span class="sr">${_("Post a Facebook message to say you've enrolled in this course")}</span>
      </a>
    % endif

    % if static.get_value('course_about_show_social_links_email', True):
      <a href="${email_link}" class="share">
        <svg xmlns="http://www.w3.org/2000/svg" width="22" height="17" viewBox="0 0 22 17" fill="none">
          <path d="M21 2.85763C21 1.83593 20.1 1 19 1H3C1.9 1 1 1.83593 1 2.85763M21 2.85763V14.0034C21 15.0251 20.1 15.861 19 15.861H3C1.9 15.861 1 15.0251 1 14.0034V2.85763M21 2.85763L11 9.35932L1 2.85763" stroke="#9CA3AF" stroke-linecap="round" stroke-linejoin="round"/>
          </svg><span class="sr">${_("Email someone to say you've enrolled in this course")}</span>
      </a>
    % endif

  </div>
  % endif
</header>

Any thoughts or opinions on such a change?

My guess is that it would be welcome! I wouldn’t be the one reviewing it (I don’t work in that area of the codebase and have a lot on my plate right now) but it seems like it’s worth proposing.

Awesome, thanks Tim :slight_smile:
I’ve thrown it into the issue queue on github for the relevant parties to asses viability

It sure did. Thank you :star_struck: