Skip to content

Commit

Permalink
faq module with schema
Browse files Browse the repository at this point in the history
  • Loading branch information
siddik-web committed Aug 27, 2022
0 parents commit 88e7170
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 0 deletions.
30 changes: 30 additions & 0 deletions mod_faq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @package Joomla.Site
* @subpackage mod_faq
*
* @copyright (C) 2022 Md Siddiqur Rahman
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ModuleHelper;

$faqs = $params->get('advance_faq');

$data = [];
foreach ($faqs as $faq)
{
$items = [
"@type" => "Question",
"name" => $faq->question,
"acceptedAnswer" => [
"@type" => "Answer",
"text" => $faq->answer,
]
];
array_push($data, $items);
}

require ModuleHelper::getLayoutPath('mod_faq', $params->get('layout', 'default'));
47 changes: 47 additions & 0 deletions mod_faq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" client="site" method="upgrade">
<name>mod_faq</name>
<author>Md Siddiqur Rahman</author>
<creationDate>27 Aug, 2022</creationDate>
<copyright>(C) 2022 Md Siddiqur Rahman</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://siddiqur.com</authorUrl>
<version>1.0.0</version>
<description>Advanced FAQ Module</description>

<files>
<filename module="mod_faq">mod_faq.php</filename>
<folder>tmpl</folder>
</files>

<config>
<fields name="params">
<fieldset name="basic">
<field
name="advance_faq"
type="subform"
label="Advanced FAQ's"
icon="list"
multiple="true"
>
<form hidden="true" name="faq_item" repeat="true">
<field
name="question"
type="text"
label="Question"
/>
<field
name="answer"
type="textarea"
label="Answer"
rows="3"
/>
</form>
</field>

</fieldset>
</fields>
</config>

</extension>
134 changes: 134 additions & 0 deletions tmpl/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

/**
* @package Joomla.Site
* @subpackage mod_faq
*
* @copyright (C) 2022 Md Siddiqur Rahman
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
$id = 0;
?>

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity":
<?php echo json_encode($data, JSON_PRETTY_PRINT); ?>

}
</script>

<style>

@import url(https://fonts.googleapis.com/css?family=Lato);

@import url(https://fonts.googleapis.com/css?family=Open Sans);

.faq-heading {
font-family: Lato;
font-weight: 400;
font-size: 19px;
-webkit-transition: text-indent 0.2s;
text-indent: 20px;
color: #333;
margin: 20px 0;
}

.faq-text {
font-family: Open Sans;
font-weight: 400;
color: #919191;
width:95%;
padding-left:20px;
margin-bottom:30px;
}

.faq {
width: 100%;
margin: 0 auto;
background: white;
border-radius: 4px;
position: relative;
border: 1px solid #E1E1E1;
margin-bottom: 20px;
}
.faq label {
display: block;
position: relative;
overflow: hidden;
cursor: pointer;
height: 56px;
padding-top:1px;

background-color: #FAFAFA;
border-bottom: 1px solid #E1E1E1;
}

.faq input[type="checkbox"] {
display: none;
}

.faq .faq-arrow {
width: 5px;
height: 5px;
transition: -webkit-transform 0.8s;
transition: transform 0.8s;
transition: transform 0.8s, -webkit-transform 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
border-top: 2px solid rgba(0, 0, 0, 0.33);
border-right: 2px solid rgba(0, 0, 0, 0.33);
float: right;
position: relative;
top: -30px;
right: 27px;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}

.faq input[type="checkbox"]:checked + label > .faq-arrow {
transition: -webkit-transform 0.8s;
transition: transform 0.8s;
transition: transform 0.8s, -webkit-transform 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
-webkit-transform: rotate(135deg);
transform: rotate(135deg);
}
.faq input[type="checkbox"]:checked + label {
display: block;
background: rgba(255,255,255,255) !important;
color: #4f7351;
height: 225px;
transition: height 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.faq input[type='checkbox']:not(:checked) + label {
display: block;
transition: height 0.8s;
height: 70px;
-webkit-transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

::-webkit-scrollbar {
display: none;
}

</style>

<div id="faq" class="mod-faq">
<?php foreach ($faqs as $faq): ?>
<div class='faq'>
<input id='faq-<?php echo $id; ?>' type='checkbox'>
<label for='faq-<?php echo $id; ?>'>
<p class="faq-heading"><?php echo $faq->question; ?></p>
<div class='faq-arrow'></div>
<p class="faq-text"><?php echo $faq->answer; ?></p>
</label>
</div>
<?php $id++;?>
<?php endforeach;?>
</div>

0 comments on commit 88e7170

Please sign in to comment.