using phpBB3 variables in custom php - 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 -->

Related

Removing class in WordPress plugins file - not working without page refresh for the first time

I have a class called event-manager in a wordpress php file in the plugins folder. They are using this class to style the elements, and I am using a custom css to over-write this. The problem is I cannot overwrite their css so I had to remove this class all-together.
I need to remove this class dynamically, removing manually every-time is pointless, because every-time the plugin gets updated the class comes back.
And here the html structure. The class appears on two different pages and on both pages the image alignment is different.
<!-- Home page -->
<div class="some-class">
<div class="some-more-class">
<div class="featured-image"> <!-- this image alignment is different -->
<div class="event-image"> <!-- this div is generated dynamically from the plugin -->
some link
</div>
</div>
</div>
</div>
<!-- Blog single -->
<div class="some-class">
<div class="some-more-class">
<div class="featured-img"> <!-- and image alignment is different -->
<div class="event-image"> <!-- this div is generated dynamically from the plugin -->
some link
</div>
</div>
</div>
</div>
To acheive this I used jquery .removeClass method.
$(function(){
$(".featured-img > div, .featured-image > div").removeClass("event-manager");
});
I also tried this
$(function(){
$(".featured-img > div").removeClass("event-image");
$(".featured-image > div").removeClass("event-image");
});
And this
var featuredimg = ['.featured-img > div','.featured-image > div'];
$(featuredimg.join()).removeClass('event-image');
On all these methods, the class seems to be removed, because its on two different pages, when I load the homepage.php for the first time, the class is removed but when I go to single.php, it did not remove automatically and when I refresh the page, the class removes. I am not sure why.
Can anyone help me.
Thanks.
In my opinions it is related with caching. Do you have any? If yes disable it to test if works without it. If no you can check on developer console if do you have any errors. Issue can be also with place the script like this (prefer at the end of the page).

Adding HTML to a WordPress site

I tried to add a CTA to a WordPress site. I placed on the header and I added this HTML code to the header.php
<!-- This is my extra div element-->
<div class="extra-top"> <?php echo ' <a class="extra-topie" href="tel:6172010333">Call Us Now: (617) 201-0333</a> '; ?></div>
<!-- Ends extra div element-->
But the Anchor text is not working: it's not clickable yet.
For me work... But why you insert PHP echo if not use no variable?
Try this:
<!-- This is my extra div element-->
<div class="extra-top"><a class="extra-topie" href="tel:6172010333">Call Us Now: (617) 201-0333</a></div>
<!-- Ends extra div element-->
This suppose to work both the PHP and Direct HTML if you place it the right place.
If it is still not clickable, that mean you have issue with associated Application to handle dialer in Windows.. try from mobile and it should show its working.
Just tried that on my WordPress, it didn't work in desktop because I don't have default phone dialer ..but worked from mobile.

php include only part of an external page not all of it

using php's include is possible to include part of another page without including all that entire content of that page?
From pageX.php i want Div #A not div #B the whole pageX.php
<div id="A">
<p>Don't show me</p>
</div>
<div id="B">
<p>Display Me</p>
</div>
i'm aware of JQuery's ajax Load but im wondering if there's a method like that in php.
I am not aware of any function that can include a specific part of a php file but typically this can be achieved in two ways.
Split your UI component markups into separate files so that can be included separately and easily re-used in many places. (example here)
Have all the UI components markups as different functions in a common file which can be called easily.
function printDivA() {
echo <<< DIV_A
<div id="A">
<p>Don't show me</p>
</div>
DIV_A;
}

Issue with TYPO3 extension and template

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.

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 -->

Categories