In my extension I tried to make an IRRE. Finally the Backend works fine but the frontend is my problem. I want to use a normal fluid template but all names I try are empty.
So here the fluid:
<h2 class="termin">
{data.header}
<f:if condition="{data.tx_examples_noclap} == 1">
<f:then><b class="showFullDrop"></b></f:then>
</f:if>
</h2>
<f:if condition="{data.tx_examples_noclap} == 1">
<f:then><div class="teaser-full"></f:then>
<f:else><div class="teaser-full-show"></f:else>
</f:if>
<div class="text">{data.bodytext}</div>
<div class="table">
<table border="1">
{termine}
<f:for each="{termine}" as="termin">
<tr>
<td>{termin.title}</td>
<td>{termin.termin2}</td>
<td>{termin.termin3}</td>
<td style="background:{termin.farbe}">{termin.platz}</td>
</tr>
</f:for>
</table>
</div>
</div>
Here the typoScript
tt_content.stalla_hp_distribution_termin = COA
tt_content.stalla_hp_distribution_termin {
10 = FLUIDTEMPLATE
10 {
file = EXT:stalla_hp_distribution/Resources/Private/Template/Termin.html
stdWrap.dataWrap = <div id="c{field:uid}" class="termin">|</div>
}
}
Here the Controler..
1.Classes/Domain/Model/Termin.php
<?php
namespace stalla_hp_distribution\Domain\Model;
/**
*
*
* #package stalla_hp_distribution
* #license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class Termin extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
protected $farbe = NULL;
protected $title = NULL;
protected $termin2 = NULL;
protected $termin3 = NULL;
protected $platz = NULL;
public function getFarbe(){
return $this->farbe;
}
public function getTitle(){
return $this->title;
}
public function getTermin2(){
return $this->termin2;
}
public function getTermin3(){
return $this->termin3;
}
public function getPlatz(){
return $this->platz;
}
public function setFarbe(){
$this->farbe = $farbe;
}
public function setTitle(){
$this->title = $title;
}
public function setTermin2(){
$this->termin2 = $termin2;
}
public function setTermin3(){
$this->termin3 = $termin3;
}
public function setPlatz(){
$this->platz = $platz;
}
}
?>
2. Classes/Domain/Repository/TerminRepository.php
<?php
namespace stalla_hp_distribution\Domain\Repository;
class TerminRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
}
?>
3. Classes/Controller/TerminController.php
<?php
namespace stalla_hp_distribution\Controller;
/**
* TerminController
*/
class TerminController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* #var stalla_hp_distribution\Domain\Repository\TerminRepository
* #inject
*/
protected $terminRepository;
/**
* action list
*
* #return void
*/
public function listAction() {
$termine = $this->terminRepository->findAll();
$this->view->assign('termine', $termine);
}
}
?>
I'm looking forward to hearing from You.
Kind Regards
Ascawath
If you can reference many titles to a termin, try this
...
<div class="text">{data.bodytext}</div>
<table border="1">
<f:for each="{termine}" as="termin">
<tr>
<f:for each="{termin.title}" as="title" iteration="iterator">
<f:if condition="{iterator.isFirst}">
<td>{title}</td>
</f:if>
</f:for>
...
</tr>
</f:for>
</table>
</div>
You could use the DatabaseQueryProcessor to access the Data of your IRRE and make it available in your Fluid Template
Here is an Example TS
tt_content.slickcarouselbgimg = FLUIDTEMPLATE
tt_content.slickcarouselbgimg {
templateName = Slickcarouselbgimg
templateRootPaths {
10 = EXT:slickcarousel/Resources/Private/Templates/
}
partialRootPaths {
10 = EXT:slickcarousel/Resources/Private/Partials/
}
layoutRootPaths {
10 = EXT:slickcarousel/Resources/Private/Layouts/
}
dataProcessing {
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
table = tx_slickcarouselbgimg
pidInList.field = pid
where {
data = field:uid
intval = 1
wrap = tt_content=|
}
orderBy = sorting
as = slides
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
as = images
}
}
}
}
}
Here you could see the whole setup:
https://github.com/misterboe/slickcarousel
Related
In my extbase repository I've built a similar query function as described in this tutorial: this and it was using a filter object, $demand.
So I created a class for my filter as well in order to work with an object in fluid.
It works, but only once - I can change something, click on "Filter" and it works.
But if I change something again and click on "Filter" it jumps back to the previous values and nothing changes.
I feel like this might have something to do with caching, but I'm not sure.
When I debug the filter object it doesn't show my the debug code after the second click on "Filter" because that's what it does when nothing has changed I noticed.
What can I do to change my filter settings as many times as I want?
My filter class:
class AppointmentFilter extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* future
*
* #var int
*/
protected $future = 1;
/**
* booked
*
* #var int
*/
protected $booked = 2;
/**
* student
*
* #var \vendor\extension\Domain\Model\Student
*/
protected $student = NULL;
/**
* expertise
*
* #var \vendor\extension\Domain\Model\Expertise
*/
protected $expertise = NULL;
function getFuture() {
return $this->future;
}
function getBooked() {
return $this->booked;
}
function getStudent() {
return $this->student;
}
function getExpertise() {
return $this->expertise;
}
function setFuture($future) {
$this->future = $future;
}
function setBooked($booked = NULL) {
$this->booked = $booked;
}
function setStudent(\vendor\extension\Domain\Model\Student $student = NULL) {
$this->student = $student;
}
function setExpertise(\vendor\extension\Domain\Model\Expertise $expertise = NULL) {
$this->expertise = $expertise;
}
}
And the corresponding fluid form:
<f:form action="list" name="appointmentFilter"
class="filter-form"
object="{appointmentFilter}"
arguments="{students:students,expertises:expertises}">
Termine:
<label>
<f:form.radio property="future" value="1"/> Bevorstehende
<f:form.radio property="future" value="0"/> Vergangene
</label>
<label>
<f:form.radio property="booked" value="2"/> Alle
<f:form.radio property="booked" value="1"/> Gebuchte
<f:form.radio property="booked" value="0"/> Freie
</label>
<label>
Studenten:
<f:form.select property="student" options="{students}" optionLabelField="fullName" prependOptionLabel="Alle Studenten" class="filterSelect" />
</label>
<label>
Expertise:
<f:form.select property="expertise" options="{expertises}" optionLabelField="name" prependOptionLabel="Alle" class="filterSelect" />
</label>
<f:form.submit value="Filter anwenden" class="rm-with-js" />
</f:form>
According to your description this is a caching problem. You can set your action to be noncachable by adding it in the second array in the plugin configuration in the localconf.php. Example:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
$_EXTKEY,
'Pi1',
array(
'Controller' => 'list, cachedAction',
),
// this is the array for noncachable actions
array(
'Controller' => 'list',
)
);
I have a requirement to create breadcrumb in sightly. I have following code which is working fine in JSP. But i am struggling to convert the code to sightly because i am not getting the right methods in currentStyle object to get the "absParent" and others. Any help will be highly appreciated!!
<%# include file="/libs/foundation/global.jsp" %>
<%
final int startLevel = currentStyle.get("absParent", 3);
final int endLevel = currentPage.getDepth() - currentStyle.get("relParent", 0);
final int minItems = currentStyle.get("minItems", 2);
if (startLevel <= endLevel - minItems) {
%><section class="breadcrumbs"><%
for (int level = startLevel+1; level < endLevel; ++level) {
Page itemPage = currentPage.getAbsoluteParent(level);
if (itemPage == null || !itemPage.isValid() || itemPage.isHideInNav()) {
continue;
}
final String pagePath = itemPage.getPath() + ".html";
final String pageTitle = itemPage.getNavigationTitle();
String className = "breadcrumb-item-"+level;
if (level == startLevel) className += " breadcrumb-first";
if (level == endLevel-1) className += " breadcrumb-last";
pageContext.setAttribute("className", className);%>
<section class="breadcrumbs ">
<%= xssAPI.encodeForHTML(pageTitle) %>
</section>
<%} %>
</section><%
}
%>
To create breadcrumb you have to write a WCMuse class and include that in this component.
<div
data-sly-use.breadcrumb="${'com.mySite.components.BreadcrumbUse'}">
<!-- + Breadcrumb component + -->
<div class="breadcrumb component">
<div class="breadcrumb_nav_bar clearfix"
data-sly-test="${breadcrumb.navList}"
data-sly-list.element="${breadcrumb.navList}">
<p data-sly-test="${!elementList.last}">
<a href="${element.path}.html">${element.title ||
element.navigationTitle || element.name}</a>
</p>
<p data-sly-test="${elementList.last}">${element.title ||
element.navigationTitle || element.name}</p>
</div>
</div>
<!-- - Breadcrumb component - -->
</div>
Code Sample for WCMUse class:
Public class BreadcrumbUse extends WCMUse
{
private List<Page> navList = new ArrayList<Page>();
#Override
public void activate() throws Exception
{
setBreadCrumbItems();
}
private void setBreadCrumbItems()
{
long level = 4L;
long endLevel = 1L;
int currentLevel = getCurrentPage().getDepth();
while (level < currentLevel - endLevel)
{
Page trailPage = getCurrentPage().getAbsoluteParent((int) level);
if (trailPage == null)
{
break;
}
this.navList.add(trailPage);
level++;
}
}
public List<Page> getNavList()
{
return this.navList;
}
}
The below code will work for creating breadcrumbs in AEM6.2 using Javascript and HTL(previously sightly).It worked well for me..here we go
Javascript to be used in the server side script(it can also be created using java)
script.js
use(function () {
var title = currentPage.getTitle();
//To get the title of the current page
var level = currentPage.getDepth();
//To find the depth of the current page from the root
var cts = new Array();
// To store the traversed page (object) from the root
for(var i=1;i<level;i++)
{ // Here I used i=1 for mycase(i=0 will be /content)
var titl = currentPage.getAbsoluteParent(i);
//To get the absolute parent at each level from root
pageStack.push(titl);
//Stack to maintain the pages
}
return {
title: title,
pageStack:pageStack
};
});
Breadcrumbs.html
<sly data-sly-use.cpt="script.js">
<h1>${cpt.title}</h1>
<div data-sly-list="${cpt.pageStack}">
<span> ${item.title}/</span>
</div>
</div>
Thus we get the breadcrumbs ready for our presentation!!!
I am trying to make a registration form in laravel 5 and it gives me this error:
Whoops, looks like something went wrong.
1/1
TokenMismatchException in compiled.php line 2440:
This is my views/register.blade.php:
<form class="form-horizontal" action = "inregistrare_process" method = "POST">
.....
</form>
This is in my app/Register.php
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Register extends Eloquent {
protected $guarded = array();
protected $table = 'users';
public $timestamps = 'false' ;
public static function saveFormData($data)
{
DB::table('users')->insert($data);
}
}
This is my Controllers/RegisterController.php
<?php namespace App\Http\Controllers;
use App\Register;
class RegisterController extends Controller {
public function store()
{
Register::saveFormData(Input::except(array('_token')));
}
}
And this is in my routes.php
Route::get('inregistrare',function(){
return view('register');
});
Route::post('inregistrare_process', function()
{
$obj = new RegisterController() ;
return $obj->store();
});
Can someone help me make this work or give me another alternative on how to make the registration page work ?
First of all you need a hidden input type with csrf_token in form
insert below line after your form declaration
<input type="hidden" name="_token" value="{{ csrf_token() }}">
Do you have write permission for your session file. By default session is stored in /storage/framework/sessions/
check that you have write permission on that directory.
If you are using an Ajax request than add the tokenMatch() method to app/Http/Middleware/VerifyCsrfToken.php.
protected function tokensMatch($request)
{
$token = $request->ajax() ? $request->header('X-CSRF-Token') : $request->input('_token');
return $request->session()->token() == $token;
}
and add this in your js file
$.ajaxSetup(
{
headers:
{
'X-CSRF-Token': $('input[name="_token"]').val()
}
});
Is it possible for to display in a column instead of side by each?
The Radio options are selected in FormElement
namespace Main\Form\Element;
use Doctrine\ORM\EntityManager;
use Zend\Form\Element\Radio;
/**
* Class SurveyAnswerRadio
*
* #package Main\Form\Element
*/
class SurveyAnswerRadio extends Radio
{
/**
* #var EntityManager $entityManager
*/
protected $entityManager;
/**
* #param EntityManager $entityManager
*/
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
/**
* Get Value Options
*
* #return array
*
* #throws \Exception
*/
public function getValueOptions()
{
$array = [];
$survey_question_reference = 1;
$result = $this->entityManager
->getRepository('AMDatabase\Entity\TheVerse\SA')
->findBy(
[
'sqReference' => $survey_question_reference
],
[
'surveyAnswer' => 'ASC'
]
);
if (is_array($result) && count($result) > '0') {
/**
* #var \AMDatabase\Entity\TheVerse\SA $val
*/
foreach ($result as $val) {
$array[$val->getReference()] = $val->getSurveyAnswer();
}
}
return $array;
}
}
This is added to the Form
/**
* Survey Answer
*/
$this->add(
[
'type' => 'Main\Form\Element\SurveyAnswerRadio',
'name' => 'survey_answer',
'options' => [
'label' => 'survey_answer'
],
'attributes' => [
'id' => 'survey_answer'
]
]
);
}
Then it is displayed within a view Twig
<div class="field">
<span>{{ formLabel(form.get('survey_answer')) }}</span>
{{ formRadio(form.get('survey_answer')) }}
</div>
The output encloses each within a . I am wanting the output to be displayed in this fashion:
<ul>
<li><label><input type="radio" name="survey_answer" id="survey_answer" value="1">option 1</label><li>
<li><label><input type="radio" name="survey_answer" id="survey_answer" value="2">option 2</label></li>
<li><label><input type="radio" name="survey_answer" id="survey_answer" value="3">option 3</label></li>
</ul>
use this command in view
$this->formRadio()->setSeparator('</li><li class="yourclass">');
this command set separator between your radio options.
then you show your element like this
<li class="yourclass" >
<?php echo $this->formRadio($form->get('survey_answer')); ?>
</li>
I need to customize the attributes of my body tag. Where should I locate the logic? In a Base Controller, view Helper ?
This should be the layout
<?=$this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body<?=$this->bodyAttrs?>> <!-- or <?=$this->bodyAttrs()?> -->
...
</body>
</html>
And this should be the variables declaration in controllers
class Applicant_HomeController extends Zend_Controller_Action
{
public function indexAction()
{
$this->idBody = "someId1";
$this->classesBody = array("wide","dark");
}
public function loginAction()
{
$this->idBody = "someId2";
$this->classesBody = array();
}
public function signUpAction()
{
$this->idBody = "someId3";
$this->classesBody = array("no-menu","narrow");
}
}
This is the function where the attributes are concatenated.
/**
* #param string $idBody id Attribute
* #param array $classesBody class Attribute (array of strings)
*/
protected function _makeBodyAttribs($idBody,$classesBody)
{
$id = isset($idBody)?' id="'.$idBody.'"':'';
$hasClasses = isset($classesBody)&&count($classesBody);
$class = $hasClasses?' class="'.implode(' ',$classesBody).'"':'';
return $id.$class;
}
I need the last glue code.
Got one better for ya:
<?php
class My_View_Helper_Attribs extends Zend_View_Helper_HtmlElement
{
public function attribs($attribs) {
if (!is_array($attribs)) {
return '';
}
//flatten the array for multiple values
$attribs = array_map(function($item) {
if (is_array($item) {
return implode(' ', $item)
}
return $item;
}, $attribs);
//the htmlelemnt has the build in function for the rest
return $this->_htmlAttribs($attribs)
}
}
in your controller:
public function indexAction()
{
//notice it is $this->view and not just $this
$this->view->bodyAttribs= array('id' => 'someId', 'class' => array("wide","dark"));
}
public function loginAction()
{
$this->view->bodyAttribs['id'] = "someId2";
$this->view->bodyAttribs['class'] = array();
}
in your view script:
<body <?= $this->attribs($this->bodyAtrribs) ?>>