{% set operator = “&” if “?” in page_meta.canonical_url else “&” %}
if I understand correctly it means that apply & if there is a ? in page… else use & ??
Looks like this means the same right?
Also I see often this sign:
~
What does this sign mean exactly?
Please see the full code below:
{##
# Share Icons
#
# This module display icons to share current content or
# custom link in networks.
#
# @Field type Boolean {module.isActive} Shows or hides the module. Accept 'true' or 'false'. Default 'true'.
# @Field type Text {module.title} Module main title.
# @Field type Link {module.link} Field thats enable to customize the url to share.
# @Field type Group {module.networks} Group of networks options.
# {
# @Field type Boolean {module.facebook} Enable or disable share in Facebook. Default 'true'.
# @Field type Boolean {module.twitter} Enable or disable share in Twitter. Default 'true'.
# @Field type Boolean {module.linkedin} Enable or disable share in LinkedIn. Default 'true'.
# @Field type Boolean {module.pinterest} Enable or disable share in Pinterest. Default 'true'.
# @Field type Boolean {module.whatsapp} Enable or disable share in Whatsapp. Default 'true'.
# @Field type Boolean {module.email} Enable or disable share in Email. Default 'true'.
# }
#}
{# Define the module internal name #}
{% set module_slug = "share-content" %}
{# Macro to define each network url #}
{% macro networkUrl( network ) %}
{# Variables #}
{% set custom_url = module.link.url.href %}
{% set canonical_url = page_meta.canonical_url %}
{% set operator = "&" if "?" in page_meta.canonical_url else "&" %}
{% set page_title = page_meta.name %}
{# Define the final link to share #}
{% if custom_url %}
{% set url = custom_url ~ operator ~ "utm_medium=social&utm_source="|safe ~ network %}
{% else %}
{% set url = canonical_url ~ operator ~ "utm_medium=social&utm_source="|safe ~ network %}
{% endif %}
{# Define the final url to each network #}
{% if network == 'facebook' %}
{{ "http://www.facebook.com/share.php?u=" ~ url }}
{% elif network == 'twitter' %}
{{ "https://twitter.com/ubiqum" ~ url ~ "&url=" ~ url ~ "&source=tweetbutton&text=" ~ page_meta.html_title|urlencode ~ ": " }}
{% elif network == 'linkedin' %}
{{ "https://www.linkedin.com/school/ubiqum-academy/mycompany/" ~ url }}
{% elif network == 'pinterest' %}
{{ "http://pinterest.com/pin/create/button/?url=" ~ url ~ "&media=" ~ pinterest_media }}
{% elif network == 'whatsapp' %}
{{ "whatsapp://send?text=" ~ page_meta.html_title|urlencode ~ ": " ~ url }}
{% elif network == 'email' %}
{{ "mailto:?subject=" ~ page_title|urlencode ~ "&body=" ~ page_meta.html_title|urlencode ~ ": " ~ url }}
{% endif %}
{% endmacro %}
{# Macro to define the network list item #}
{% macro networkItemList( network ) %}
{% if module.networks[network] %}
<li class="{{ module_slug }}-item {{ module_slug }}-item-{{ network }}">
<a href="{{ networkUrl( network ) }}" title="Share in {{ network|capitalize }}" onclick="return false;">
<img src="{{ module_asset_url("icon-" ~ network ~ ".png") }}" alt="{{ network|capitalize }} icon">
</a>
</li>
{% endif %}
{% endmacro %}
{# The module code starts here #}
{% if module.isActive %}
<div id="{{ module_slug }}" class="module">
<div class="{{ module_slug }}-wrapper {{ module.title_position }}-title">
{# Header #}
{% if module.title %}
<div class="{{ module_slug }}-header">
<h3>{{ module.title }}</h3>
</div>
{% endif %}
{# Listing #}
<ul class="{{ module_slug }}-listing">
{{ networkItemList( 'facebook' ) }}
{{ networkItemList( 'twitter' ) }}
{{ networkItemList( 'linkedin' ) }}
{{ networkItemList( 'pinterest' ) }}
{{ networkItemList( 'whatsapp' ) }}
{{ networkItemList( 'email' ) }}
</ul>
</div>
</div>
{% endif %}
Thanks for your help already!