Issue with TYPO3 extension and template - php

I am reading a TYPO3 extension.
This is the template file:
<!-- ###LIST_LATEST### begin -->
<div class="latest-wrapper">
<ul class="listing latest">
<li><h1>###LIST_HEADER###</h1></li>
<!-- ###LOOP### --><!-- ###ITEM### --><li>
<span class="category">###CATEGORY###</span><span class="company">###COMPANY_NAME###</span><span class="location">###LOCATION###, ###STATE### ###ZIP###</span>
</li><!-- ###ITEM### --><!-- ###LOOP### -->
<li class="more">###MORE###</li>
</ul>
</div>
<!-- ###LIST_LATEST### end -->
In class.tx_jcjob_pi1.php, when put the contents into the template file, seems there are two ways:
a. for ###MORE###, use this method:
$markerArray['###MORE###'] = $this->cObj->getTypoLink($this->pi_getLL('text_link_more'), $this->conf['searchID'], array('tx_ajaxsearch_pi1[keyword]' => ''));
$content = $this->cObj->substituteMarkerArray($template, $markerArray);
b. for <!-- ###LOOP### -->, use this method:
$template = $this->cObj->substituteSubpart($template, '###LOOP###', $loopContent); var_dump($template);
So my question is:
What is the difference between ###MORE### and <!-- ###LOOP### -->?
What is the difference between substituteMarkerArray and substituteSubpart?

You are asking for the difference between two basic templating tools in TYPO3:
Markers (###MORE###) and
Subparts (<!-- ###LOOP### -->)
Both are placeholders to be replaced with dynamic content.
A marker represents a singular occurance. The string ###MORE### will be replaced by the function substituteMarker() or substituteMarkerArray() with whatever value you define in your php code.
A subpart always occurs in pairs; it has a beginning and an end marker. They enclose a range of code within which more values can be replaced. In your case, everything between the two <!-- ###LOOP### --> strings you find in your template can be processed by the function substituteSubpart(). Usually, this is used for list views when you loop over multiple results from your query. Within each subpart element you can replace markers or subparts recursively in your php code.
This blog post might give you some more insight into the principles.

Related

Gutenberg block Social links problem with render

When I add block Social links in the template part and after that choose this template part with block Template part - nothing is rendering. Why it's happening? Maybe attributes don't pass trough blocks in this case? but it looks like a bug in the core.
<!-- wp:social-links -->
<ul class="wp-block-social-links">
<!-- wp:social-link /-->
</ul>
<!-- /wp:social-links -->
Or when I create a template part like this - is any possible way to pass dynamically attributes from the editor to template part instead hardcoded url?
<!-- wp:social-links -->
<ul class="wp-block-social-links">
<!-- wp:social-link {"url":"https://wordpress.org/patterns/","service":"instagram"} /-->
<!-- wp:social-link {"url":"https://wordpress.org/patterns/","service":"bandcamp"} /-->
<!-- wp:social-link {"url":"https://wordpress.org/patterns/","service":"twitter"} /-->
<!-- wp:social-link {"url":"https://wordpress.org/patterns/","service":"twitch"} /-->
I try to add block Social Links in the template part and need to have the opportunity to choose template part with social links with block Template Part. And seeing results on the frontend.
When the Social Links block is inserted into the template part, a valid link for each social you add, eg "Instagram", "Bandcamp", etc... is required otherwise it will not render a link on the frontend - producing the markup posted in your question.
To insert the Social Links block into multiple template parts without having to set the URLs each time, convert your configured Social Links block to a Reusable Block. By using a Reusable Block in your templates, you will also be able to easily update/add/remove your social links site-wide in the future if needed.

using phpBB3 variables in custom php

I'm implementing a custom php script within the viewforum loop to add voting. I need to pass {topicrow.TOPIC_ID} to the voteHTML(), where $itembid currently is. It renders the data-did perfectly through the loop. How do I get the variable value through to the php block?
<span class="topid" data-did="{topicrow.TOPIC_ID}" ></span>
<!-- PHP -->
echo $pulse->voteHTML($itembid);
<!-- ENDPHP -->

What is the preferred template control to handle unassigned variables in PHPBB3?

I'm trying to handle a control case where a variable is not defined.
This is what seems to work, but is also ugly. Any ways to make this work better?
<!-- IF UNASSIGNED_VARIABLE -->
<!-- ELSE -->
<insert code here>
<!-- END -->
I tried a few different negation structures, but they only worked when the template variable was defined.
Common operators are described on the wiki
<!-- IF not UNASSIGNED_VARIABLE -->
<insert code here>
<!-- END -->

jquery mobile header repeat across pages

I'm setting up a multi-page jquery mobile page based on the provided template:
http://jquerymobile.com/demos/1.1.1/docs/pages/multipage-template.html
How can I get the header/footer to repeat on all the pages without duplicating it in the page content.
Is there a jquery script for this or do I have to use some kind of php include file?
Thanks in advance!
You can use JS (jQuery) to make a template and append it to each data-role="page" element as it's being created.
//create template, notice the "{TITLE}" place-holder for dynamically adding titles
var myHeaderHTML = '<div data-role="header" data-id="my-header" data-position="fixed"><h1>{TITLE}</h1></div>';
//create delegated event handler for the "pagecreate" event for all pseudo-pages
$(document).on('pagecreate', '[data-role="page"]', function () {
//get the title of this page, if none is given then use a generic title
var title = $(this).data('title') || 'Some Generic Title';
//add the header to this pseudo-page
$(this).append(myHeaderHTML.replace('{TITLE}', title));
});​
Here is a demo: http://jsfiddle.net/vmMVj/
This will append a fixed header to every page as it is being created. I added support for passing a unique title by adding a data-title="Some Title" attribute to the data-role="page" element.
Note that I chose the pagecreate event because it occurs when the pseudo-page is about to be initialized. If you were to bind to the pageinit event, you'd be too late and have to initialize the header widget manually.
As far as I know, you must include a header and footer within each data-role="page" container. If you wan't to avoid typing this out for each page, then I would require_once() a page in PHP that includes the header or footer, and use that in place of writing out a header and footer each time.
Sample:
<section data-role="page">
<?php require_once("header.php"); ?>
<div data-role="content">
<p>Hello world!</p>
</div>
<?php require_once("footer.php");?>
</section>
header.php:
<header data-role="header">
<h1>Title</h1>
</header>
footer.php:
<footer data-role="footer">
<<p>Footer content here</p>
</footer>
Why more JS ?? ... instead of adding two elements for header and footer (either "header" and "footer" tags, or divs with appropriate classes, but mandatory with "position: fixed;") - and add padding top and bottom of the pages divs ? ... No JS code needed ... which will improves the performance ... although very little :) ...

How to add logic to PHPBB template file?

How do we apply logic in template file of phpBB?
The way they have taught in the tutorial doesnt works for me.
I have used this:
$template->assign_var('POINTER',$pointer);
and in the .tpl file
!-- IF POINTER == 1 -->
do this
!-- ELSE -->
do that
!-- ENDIF -->
But it doesn't work.
1.) Are you using PHPBB3 or 2? Because the IF-Condtion exists only in Version 3.
2.) You know that the "<"-Sign is missing at the begin of your Code?
You have a few errors in your code:
// There wasn't anything wrong with the PHP code
$pointer = 1;
$template->assign_var('POINTER', $pointer);
In the template file:
<!-- IF POINTER == 1 -->
<div>Pointer is 1</div>
<!-- ELSE -->
<div>Pointer is not 1</div>
<!-- ENDIF -->
Errors:
HTML comments (and phpBB instruction blocks) start with <!--
There's only one space after <!-- (you had two for ENDIF)

Categories