Skip to content

Commit

Permalink
Phone as optional option
Browse files Browse the repository at this point in the history
  • Loading branch information
magentix committed May 12, 2023
1 parent 8548a06 commit 43b82af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pixel_googlemybusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Pixel_googlemybusiness extends Module implements WidgetInterface
public function __construct()
{
$this->name = 'pixel_googlemybusiness';
$this->version = '1.0.3';
$this->version = '1.0.4';
$this->author = 'Pixel Open';
$this->tab = 'front_office_features';
$this->need_instance = 0;
Expand Down Expand Up @@ -102,7 +102,7 @@ public function getWidgetVariables($hookName, array $configuration): array
explode(',', $configuration['place_ids'] ?? '')
);
$display = array_filter(
explode(',', $configuration['display'] ?? 'name,rating,opening-hours,reviews')
explode(',', $configuration['display'] ?? 'name,phone,rating,opening-hours,reviews')
);
$reviewNumber = $configuration['review_number'] ?? 5;
$reviewMinRating = $configuration['review_min_rating'] ?? 0;
Expand Down Expand Up @@ -282,7 +282,7 @@ protected function createTables(): bool
`place_id` VARCHAR(255) NOT NULL,
`language` VARCHAR(2) NULL,
`name` VARCHAR(255) NOT NULL,
`phone` VARCHAR(255) NOT NULL,
`phone` VARCHAR(255) DEFAULT NULL,
`opening_hours_periods` TEXT DEFAULT NULL,
`opening_hours_weekday_text` TEXT DEFAULT NULL,
`rating` NUMERIC(4, 2) DEFAULT NULL,
Expand Down
20 changes: 11 additions & 9 deletions pixel_googlemybusiness.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<div class="place" itemscope itemtype="https://schema.org/Place">
{if 'name'|in_array:$display}
<div class="name" itemprop="name">{$place->getName()}</div>
<div><a href="tel:{$place->getPhone()}"><i
class="material-icons">&#xE0B0;</i><span
itemprop="telephone">{$place->getPhone()}</span></a></div>
{/if}
{if 'phone'|in_array:$display and $place->getPhone()}
<div class="phone"><a href="tel:{$place->getPhone()}"><span itemprop="telephone">{$place->getPhone()}</span></a></div>
{/if}
{if 'rating'|in_array:$display}
<div class="rating" itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
{if $place->getUserRatingsTotal()}
<meta itemprop="ratingValue" content="{$place->getRating()}"/>
<meta itemprop="reviewCount" content="{$place->getUserRatingsTotal()}">
<meta itemprop="ratingValue" content="{$place->getRating()}" />
<meta itemprop="reviewCount" content="{$place->getUserRatingsTotal()}" />
{l s='Note:' d='Modules.Pixelgooglemybusiness.Shop'} <strong>{$place->getRating()}/5</strong> ({$place->getUserRatingsTotal()} {l s='reviews' d='Modules.Pixelgooglemybusiness.Shop'})
{else}
<a href="https://www.google.com/maps/search/?api=1&query=Google&query_place_id={$place->getPlaceId()}" target="_blank" rel="noopener noreferrer">
Expand All @@ -31,13 +31,15 @@
<div class="reviews">
{foreach from=$place->getReviews() item=review}
<div class="review" itemprop="review" itemscope itemtype="https://schema.org/Review">
<a href="{$review->getAuthorUrl()}" title="{$review->getAuthorName()}"><span class="author" itemprop="author">{$review->getAuthorName()}</span></a>
<a href="{$review->getAuthorUrl()}" title="{$review->getAuthorName()}" rel="nofollow">
<span class="author" itemprop="author">{$review->getAuthorName()}</span>
</a>
<span class="date" itemprop="datePublished" content="{$review->getTime()|date_format:"%Y-%m-%d"}">{$review->getTime()|date_format:"%e %B %Y"}</span>
<span class="note" itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating">
{$review->getRating()}/5
<meta itemprop="worstRating" content = "1">
<meta itemprop="ratingValue" content="{$review->getRating()}"/>
<meta itemprop="bestRating" content = "5">
<meta itemprop="worstRating" content = "1" />
<meta itemprop="ratingValue" content="{$review->getRating()}" />
<meta itemprop="bestRating" content = "5" />
</span>
{if $review->getComment()}
<div class="comment" itemprop="reviewBody">
Expand Down
4 changes: 4 additions & 0 deletions views/css/gmb.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
font-size: 1.1rem;
}

.google-places .place .phone {
margin-bottom: 1rem;
}

.google-places .place .rating {
margin-bottom: 1rem;
}
Expand Down

0 comments on commit 43b82af

Please sign in to comment.