From 5d2bc788cd8f455f437380e6854d2665bca3b3f4 Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Thu, 26 Sep 2024 10:50:48 +0700 Subject: [PATCH] Update Testimonial Widget - Add Rating Option --- .../elements/testimonials/testimonials.php | 24 ++++++++++++++++++- .../elements/testimonials/testimonials.xml | 4 ++++ language/en-GB/en-GB.astroid.ini | 4 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/framework/elements/testimonials/testimonials.php b/framework/elements/testimonials/testimonials.php index 97deaf6c..aeed0ea9 100644 --- a/framework/elements/testimonials/testimonials.php +++ b/framework/elements/testimonials/testimonials.php @@ -207,10 +207,13 @@ $overlay_text_color = $params->get('overlay_text_color', ''); $overlay_text_color = $overlay_text_color !== '' ? ' ' . $overlay_text_color : ''; + +$enable_rating = $params->get('enable_rating', 0); echo '
'; foreach ($testimonials as $key => $testimonial) { $testimonial_params = Helper::loadParams($testimonial->params); $avatar = $testimonial_params->get('avatar', ''); + $rating = $testimonial_params->get('rating', 0); $media = ''; if ($avatar) { $media = '
'; @@ -218,7 +221,6 @@ $media .= '
'; } - echo '
'; if ($avatar_position == 'left' || $avatar_position == 'right') { echo '
'; @@ -243,6 +245,21 @@ if ($avatar_position == 'bottom') { echo $media; } + if (!empty($enable_rating)) { + echo '
'; + for ($i = 0; $i < 5 ; $i++) { + if ($i < $rating) { + if ($rating - $i >= 1) { + echo '
'; + } else { + echo '
'; + } + } else { + echo '
'; + } + } + echo '
'; + } if (!empty($testimonial_params->get('designation', '')) && $designation_position == 'before') { echo '
' . $testimonial_params->get('designation', '') . '
'; } @@ -310,4 +327,9 @@ } if (!empty($dot_alignment)) { $element->style->child('.astroid-slick .slick-dots')->addCss('text-align', $dot_alignment); +} +if (!empty($enable_rating)) { + $rating_color = Style::getColor($params->get('rating_color', '')); + $element->style->child('.as-rating-block')->addCss('color', $rating_color['light']); + $element->style_dark->child('.as-rating-block')->addCss('color', $rating_color['dark']); } \ No newline at end of file diff --git a/framework/elements/testimonials/testimonials.xml b/framework/elements/testimonials/testimonials.xml index bbacc854..6ae114af 100644 --- a/framework/elements/testimonials/testimonials.xml +++ b/framework/elements/testimonials/testimonials.xml @@ -15,6 +15,7 @@ +
@@ -25,6 +26,7 @@ +
@@ -455,6 +457,8 @@ + +
diff --git a/language/en-GB/en-GB.astroid.ini b/language/en-GB/en-GB.astroid.ini index cc73b4bc..314ffb0c 100644 --- a/language/en-GB/en-GB.astroid.ini +++ b/language/en-GB/en-GB.astroid.ini @@ -1035,6 +1035,7 @@ ASTROID_WHATS_GOOD_DESC="Pro's
multiple pro's can be listed (one per line)." ASTROID_WHATS_BAD="What's Bad" ASTROID_WHATS_BAD_DESC="Con's
multiple con's can be listed (one per line)." ASTROID_OVERALL_RATING="Overall Rating" +ASTROID_RATING="Rating" ASTROID_OVERALL_RATING_DESC="Give an overall rating for an article." ASTROID_CALL_ACTION_BUTTON="Call to Action button" ASTROID_CALL_ACTION_BUTTON_DESC="Enter text for the Call to Action button." @@ -1565,6 +1566,7 @@ ASTROID_WIDGET_TESTIMONIALS_DESIGNATION_LABEL="Designation" ASTROID_WIDGET_TESTIMONIALS_AVATAR_POSITION_LABEL="Avatar Position" ASTROID_WIDGET_NAME_OPTIONS_LABEL="Name Options" ASTROID_WIDGET_MESSAGE_OPTIONS_LABEL="Message Options" +ASTROID_WIDGET_RATING_OPTIONS_LABEL="Rating Options" ASTROID_WIDGET_TESTIMONIALS_DESIGNATION_POSITION_LABEL="Designation Options" ASTROID_WIDGET_AVATAR_OPTIONS_LABEL="Avatar Options" ASTROID_WIDGET_XXL_COLUMN_AVATAR_WIDTH="Avatar Width 2X-Large Screen" @@ -1580,6 +1582,8 @@ ASTROID_WIDGET_DOT_ALIGNMENT="Dots Alignment" ASTROID_WIDGET_NAV_POSITION="Navigation Position" ASTROID_WIDGET_NAV_POSITION_INSIDE="Inside" ASTROID_WIDGET_NAV_POSITION_OUTSIDE="Outside" +ASTROID_WIDGET_ENABLE_RATING="Enable Rating" +ASTROID_WIDGET_RATING_COLOR="Rating Color" ; Map ASTROID_WIDGET_MAP_LABEL="Map"