Coder Social home page Coder Social logo

thomasdasilva / featuretype Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thelia-modules/featuretype

0.0 0.0 0.0 167 KB

This module allows you to add to your features the features types. Example : color

License: GNU Lesser General Public License v3.0

PHP 91.49% HTML 8.51%

featuretype's Introduction

Feature Type

Authors: Thelia [email protected], Gilles Bourgeat [email protected]

  • This module allows you to add to your features the features types.
  • Example : Color, Image link to the textures ...
  • An feature can have several types.
  • An feature type can have values or not.
  • Values can be unique by language.

Scrutinizer Code Quality License Latest Stable Version

Compatibility

Thelia >= 2.1

Installation

Manually

  • Copy the module into <thelia_root>/local/modules/ directory and be sure that the name of the module is FeatureType.
  • Activate it in your thelia administration panel

Composer

Add it in your main thelia composer.json file

composer require thelia/feature-type-module:~1.3.0

Usage

  • Once activated, click on the configure button for add or edit the features types.
  • For associate an feature to an feature type, edit an feature.

Hooks

backoffice :

  • feature-type.form-top (in form : create, update, feature type) (params : feature_type_id)
  • feature-type.form-bottom (in form : create, update, feature type) (params : feature_type_id)
  • feature-type.configuration-top
  • feature-type.configuration-bottom
  • feature-type.list-action (by feature type) (params : feature_type_id)
  • feature-type.configuration-js

Loop

feature_type

Input arguments

Argument Description
id A single or a list of ids.
exclude_id A single or a list of ids.
slug String
feature_id A single or a list of features ids.

Output arguments

Variable Description
ID The feature type id
SLUG The feature type slug
TITLE The feature type title
DESCRIPTION The feature type description
CSS_CLASS The feature type css class
PATTERN The feature type pattern
INPUT_TYPE The feature type input type
MIN The feature type minimum value
MAX The feature type maximum value
STEP The feature type step value
IMAGE_MAX_WIDTH The max width for image (in px)
IMAGE_MAX_HEIGHT The max height for image (in px)
IMAGE_RATIO The image ratio required
IS_MULTILINGUAL_FEATURE_AV_VALUE Indicates whether the values are unique for each language
HAS_FEATURE_AV_VALUE Indicates whether the type feature has values for each feature av

feature_extend_feature_type

Extends the Thelia loop : Feature

Other input arguments

Argument Description
feature_type_id A single or a list of features type ids.
feature_type_slug A single or a list of features type slugs.

Other output arguments

  • The features types associated.
  • The variable name is equal to the name of the slug,
  • The value is boolean, true for associated, false for unassociated.

Example

    {loop name="feature_extend_feature_type" type="feature_extend_feature_type" feature_type_id="1,2,3"}
        {$TITLE} <br/>

        {if $COLOR}
            The feature has type color
        {/if}

        {if $MY_FEATURE_TYPE}
            The feature has type "My feature type"
        {/if}
    {/loop}

feature_availability_extend_feature_type

Extends the Thelia loop : Feature availability

Other input arguments

Argument Description
feature_type_id A single or a list of features type ids.
feature_type_slug A single or a list of features type slugs.

Other output arguments

  • The features types associated.
  • The variable name is equal to the name of the slug,
  • The variable contains the value.

Example

    title : color : my feature type
    {loop name="feature_availability_extend_feature_type" type="feature_availability_extend_feature_type" feature="1"}
        {$TITLE} : {$COLOR} : {$MY_FEATURE_TYPE} <br/>
    {/loop}

    title : color : my feature type
    {loop name="feature_availability_extend_feature_type" type="feature_availability_extend_feature_type" feature_type_slug="color"}
        {$TITLE} : {$COLOR} : {$MY_FEATURE_TYPE} <br/>
    {/loop}

feature_value_extend_feature_type

Extends the Thelia loop : Feature value

Other output arguments

  • The features types associated.
  • The variable name is equal to the name of the slug,
  • The variable contains the value.

Example

    title : color
    {loop name="feature_value_extend_feature_type" type="feature_value_extend_feature_type" feature="1" product="1"}
        {$TITLE} : {$COLOR} <br/>
    {/loop}

Model

FeatureType::getValue

    /**
     * Returns a value based on the slug, feature_av_id and locale
     *
     * <code>
     * $value  = FeatureType::getValue('color', 2);
     * </code>
     *
     * @param string $slug
     * @param int $featureId
     * @param string $locale
     * @return string
     * @throws \Propel\Runtime\Exception\PropelException
     */
    public static function getValue($slug, $featureId, $locale = 'en_US')

FeatureType::getValues

    /**
     * Returns a set of values
     * If the value does not exist, it is replaced by null
     *
     * <code>
     * $values = FeatureType::getValue(['color','texture'], [4,7]);
     * </code>
     *
     * <sample>
     *  array(
     *  'color' => [4 => '#00000', 7 => '#FFF000'],
     *  'texture' => [4 => null, 7 => 'lines.jpg']
     * )
     * </sample>
     *
     * @param string[] $slugs
     * @param int[] $featureIds
     * @param string $locale
     * @return string
     * @throws \Propel\Runtime\Exception\PropelException
     */
    public static function getValues(array $slugs, array $featureIds, $locale = 'en_US')

FeatureType::getFirstValues

    /**
     * Returns a set of first values
     * If the value does not exist, it is replaced by null
     *
     * <code>
     * $values = FeatureType::getFirstValues(['color','texture', 'other'], [4,7]);
     * </code>
     *
     * <sample>
     *  array(
     *  'color' => '#00000',
     *  'texture' => 'lines.jpg',
     *  'other' => null
     * )
     * </sample>
     *
     * @param string[] $slugs
     * @param int[] $featureIds
     * @param string $locale
     * @return array
     */
    public static function getFirstValues(array $slugs, array $featureIds, $locale = 'en_US')

FeatureType::getFeatureAv

    /**
     * Find FeatureAv by slugs, featureIds, values, locales
     *
     * <code>
     * $featureAv = FeatureType::getFeatureAv('color', '1', '#00000');
     * </code>
     *
     * @param null|string|array $slugs
     * @param null|string|array $featureIds
     * @param null|string|array $values meta values
     * @param null|string|array $locale
     *
     * @return \Thelia\Model\FeatureAv
     */
    public static function getFeatureAv($slugs = null, $featureIds = null, $values = null, $locale = 'en_US')

FeatureType::getFeatureAvs

    /**
     * Find FeatureAv by slugs, featureIds, values, locales
     *
     * <code>
     * $featureAv = FeatureType::getFeatureAvs('color', '1', '#00000');
     * </code>
     *
     * @param null|string|array $slugs
     * @param null|string|array $featureIds
     * @param null|string|array $values meta values
     * @param null|string|array $locale
     *
     * @return \Thelia\Model\FeatureAv
     */
    public static function getFeatureAvs($slugs = null, $featureIds = null, $values = null, $locale = 'en_US')

featuretype's People

Contributors

gillesbourgeat avatar lopes-vincent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.