Forum

Thread tagged as: Question, Docs, Shop

Show item if Language

Hi, Im trying to show a product list on the Perch Shop, I want to show a line if the language of my website is english and other line if they select the india one, can you help me?

Habib Anwar

Habib Anwar 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You would need to show us the code you have so far plus your Diagnostics Report as requested when you created this thread - thanks!

Well, is not like Im having a problem, Im trying to display a product list, this is what I have and it works ok

<perch:before>
    <div class="wrapper cols2-nav-right">

        <div class="primary-content">
</perch:before>
    <div class="separation50 visible-lg visible-md"></div>
    <div class="separation30 visible-sm visible-xs"></div>

    <p class="text-uppercase bold text-pink"><perch:shop id="title" type="text" /></p>

    <div class="separation20"></div>

    <perch:if not-exists="has_variants">
        <perch:form id="add_to_cart" app="perch_shop" action="shop/cart">
            <perch:input id="product" type="hidden" value="<perch:shop id="productID" env-autofill="false" />" /> 
            <perch:input type="submit" class="order-button" value="ORDER KIT" />
            <!--<a href="https://ccavenue.com" class="order-button">ORDER KIT</a>-->
        </perch:form>
    </perch:if>

    <div class="separation20"></div>
    <!--<perch:shop id="price" type="shop_currency_value" label="Price" divider-before="Pricing" size="m" min="0" step="any" />-->
    <perch:shop id="description" type="textarea" label="Description" editor="markitup" order="3" markdown="true" size="s" />

<perch:after>
</div>
</div>
</perch:after>

Now, I want that when the website is in english displays the submit button and when we are in the Indian language displays the anchor with an <perch if>

My diagnostics report:

Perch Runway: 2.8.29
Production mode: Production (100)
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_gallery (2.8.6), perch_shop_orders (1.0), perch_shop_products (1.0), perch_shop (1.0.1), perch_members (1.5), perch_mailchimp (3.0.1)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_categories (7), perch2_category_counts (0), perch2_category_sets (2), perch2_collection_index (0), perch2_collection_items (0), perch2_collection_revisions (0), perch2_collections (0), perch2_content_index (9), perch2_content_items (5), perch2_content_regions (10), perch2_gallery_albums (1), perch2_gallery_image_versions (77), perch2_gallery_images (11), perch2_mailchimp_campaigns (0), perch2_mailchimp_imports (2), perch2_mailchimp_lists (10), perch2_mailchimp_subscribers (351), perch2_mailchimp_subscriptions (351), perch2_mailchimp_webhooks (0), perch2_members (2), perch2_members_forms (1), perch2_members_member_tags (0), perch2_members_sessions (1), perch2_members_tags (0), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_routes (0), perch2_page_templates (4), perch2_pages (8), perch2_resource_log (0), perch2_resource_tags (0), perch2_resources (0), perch2_resources_to_tags (0), perch2_settings (29), perch2_shop_addresses (34), perch2_shop_admin_index (25), perch2_shop_brands (5), perch2_shop_cart (5531), perch2_shop_cart_data (168), perch2_shop_cart_items (151), perch2_shop_countries (248), perch2_shop_currencies (152), perch2_shop_customers (2), perch2_shop_emails (1), perch2_shop_index (393), perch2_shop_option_values (0), perch2_shop_options (0), perch2_shop_order_items (14), perch2_shop_order_promotions (0), perch2_shop_order_statuses (9), perch2_shop_orders (15), perch2_shop_orders_meta (1), perch2_shop_product_files (0), perch2_shop_product_option_values (0), perch2_shop_product_options (0), perch2_shop_product_tags (0), perch2_shop_products (8), perch2_shop_promotions (0), perch2_shop_search (8), perch2_shop_shipping_zone_countries (1), perch2_shop_shipping_zones (1), perch2_shop_shippings (1), perch2_shop_tax_exhibits (25), perch2_shop_tax_group_rates (1), perch2_shop_tax_groups (1), perch2_shop_tax_locations (1), perch2_shop_tax_rates (1), perch2_shop_variants (0), perch2_user_passwords (0), perch2_user_privileges (34), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_members',
        'perch_shop',
        'perch_mailchimp',
        'perch_gallery',
    );
Scheduled tasks for perch_mailchimp: import_data (1 mins)
Editor plug-ins: markitup
H1: 0562e2115afd0bf92488fdbf4f86be04
L1: b5c5f5ad01f050a5e639f47139f821cf
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #000000
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 0
content_collapseList: 1
lang: en-gb
update_2.8.29: done
perch_mailchimp_api_key: c0aa9e4e47e97069a0ff0751272d4214-us7
headerScheme: dark
update_runway_2.8.29: done
latest_version: 2.8.15
on_sale_version: 2.8.31
perch_members_login_page: /members/login.php?r={returnURL}
perch_shop_price_tax_mode: exc
perch_shop_trade_price_tax_mode: exc
perch_shop_site_url: https://
perch_shop_product_url: /shop/products/{slug}
perch_shop_default_currency: 62
perch_shop_reporting_currency: 62
perch_shop_invoice_number_format: Invoice%d
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_members_update: 1.4
perch_mailchimp_campaign_url: /mailchimp/campaign/{campaignSlug}
perch_mailchimp_secret: c97d6b9
perch_gallery_update: 2.8.5
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /home/ayzhus1/public_html
PERCH_SCHEDULE_SECRET: ae6VxcTbHAzxvLFf
PERCH_DB_USERNAME: ayzhus1_perchRunwayUser
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: ayzhus1_parchRunway
PERCH_DB_PREFIX: perch2_
PERCH_EMAIL_FROM: onlineservices@ayzh.com
PERCH_EMAIL_FROM_NAME: Habib Anwar
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/ayzhus1/public_html/perch
PERCH_CORE: /home/ayzhus1/public_html/perch/core
PERCH_RESFILEPATH: /home/ayzhus1/public_html/perch/resources
PERCH_RESPATH: /perch/resources
PERCH_HTML5: 1
PERCH_TZ: UTC
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /home/ayzhus1/public_html/perch/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile
HOSTING SETTINGS

PHP: 5.5.38
Zend: 2.5.0
OS: Linux
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: 10.0.26-MariaDB
MySQL server: 10.0.26-MariaDB
Free disk space: 206.25 GB
Extensions: Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bz2, calendar, ctype, curl, hash, filter, ftp, gettext, gmp, SPL, iconv, pcntl, readline, Reflection, session, standard, shmop, SimpleXML, mbstring, tokenizer, xml, cgi-fcgi, PDO, pdo_mysql, wddx, tidy, bcmath, imagick, gd, mysql, fileinfo, sockets, zip, xmlwriter, snmp, json, exif, intl, soap, xmlrpc, pspell, mysqli, imap, dom, mysqlnd, pdo_sqlite, Phar, xmlreader, posix, xsl, mcrypt, enchant, mhash, ionCube Loader, Zend OPcache, Zend Guard Loader
GD: Yes
ImageMagick: Yes
PHP max upload size: 2M
PHP max form post size: 8M
PHP memory limit: 128M
Total max uploadable file size: 2M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PATH: /usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REMOTE_PORT: 14561
SCRIPT_FILENAME: /home/ayzhus1/public_html/perch/core/settings/diagnostics/index.php
SERVER_ADMIN: webmaster@ayzh.com
CONTEXT_DOCUMENT_ROOT: /home/ayzhus1/public_html
REQUEST_SCHEME: http
DOCUMENT_ROOT: /home/ayzhus1/public_html
REMOTE_ADDR: 189.223.242.114
SERVER_PORT: 80
SERVER_ADDR: 108.163.252.226
SERVER_NAME: www.ayzh.com
SERVER_SOFTWARE: Apache
LD_LIBRARY_PATH: /usr/local/apache/lib
HTTP_COOKIE: cmssb=1; cmsa=1; PHPSESSID=kgn7328k0mo9dh0r5t7at2a3f4
HTTP_ACCEPT_LANGUAGE: es,en;q=0.8,en-US;q=0.6
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://www.ayzh.com/perch/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: close
HTTP_HOST: www.ayzh.com
UNIQUE_ID: V6tepGyj-OIAA6fUL2AAAABZ
FCGI_ROLE: RESPONDER
PHP_SELF: /perch/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1470848677.2526
REQUEST_TIME: 1470848677
Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you setting the language?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Pass the value into the template:

PerchSystem::set_var('lang', $lang);

and then test for it in the template:

<perch:if id="lang" value="en">
    This is English
</perch:if>

Can you give me an example? I can't make it work

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Drew gave you an example above - if you can't make it work we need to see your code now.

How I pass the value into the template?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

PerchSystem::set_var('lang', $lang);