Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Ok Daniel and thank you very much,
I tried to remove all the other functions from the PHP files and leave only this one but I have to resolve to the fact that it does not work on my installation
My php:
<?php
/*
* TTG Core Elements "PHPlugins" User Hooks v1.2 - initialization mainline
*
* developed by john bishop images (http://johnbishopimages.com)
* for Matthew Campagna of The Turning Gate (http://theturninggate.net)
*
*/
function user_load($style, $path) {
$g_tsvrl = explode(' ', $style); // Extract gallery type
define ('G_STYLE', strtoupper($g_tsvrl[1])); // and set global for later
$g_path = str_ireplace('\\','/',$path); // change \ to /
$chunks = explode('/',$g_path); // and put into array
define ('G_PATH', strtoupper($chunks[count($chunks)-2])); // gallery folder name is second to last
//define ( 'TTG_SITE', ''); // set new site root for navigation, resources, etc.
}
if (defined('BACKLIGHT_HOOK')) {
require_once(realpath(BACKLIGHT_HOOK).'/modules/module-designer/application/helpers/APHPlugins.php');
}
class PHPlugins extends APHPlugins
{
// Returns the JSON API response as an array
function dlp_get_wp_rest_response($url){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'User Agent X'
));
$posts = curl_exec($curl);
curl_close($curl);
return json_decode($posts, true);
}
function footer_bottom() {
$posts = $this->dlp_get_wp_rest_response("https://www.phototheque.nicolaslogerot.com/backlight/api/get_album/343971");
echo "Array length: " . count($posts['album']['photos']);
}
}
?>and I have this message:
Something went wrong
count(): Parameter must be an array or an object that implements Countable in perso-home.php on line 39
I cannot relaunch an album from Lightroom at this time due to work on my home network, but I will try as soon as possible
Thanks for all for your help
Nico
Oh yes thank you Rod,
Now the error is:
Something went wrong
count(): Parameter must be an array or an object that implements Countable in perso-home.php on line 147
No problem Daniel, thank you for all.
This:
function dlp_get_wp_rest_response($url){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'User Agent X'
));
$posts = curl_exec($curl);
curl_close($curl);
return json_decode($posts, true);
}
function footer_top {
$posts = $this->dlp_get_wp_rest_response("https://www.phototheque.nicolaslogerot.com/backlight/api/get_album/343971");
echo "Array length: " . count($posts['album']['photos']);
}Send me:
Something went wrong
Unexpected error: syntax error, unexpected '{', expecting '(' in perso-home.php on line 145
Line 145 is: function footer_top {
thank you very much Daniel, in fact this is a code that I have been using since version 2 of Backlight but it does not display the number of images of an album on a page without an album. I would have liked to be able to display the number of images in the footer of each page, including the pages with only text, but I have to make a reason, my limited knowledge in php does not allow me to achieve this.
Hi DavidOllila,
I put a "hero image" in my search page from Backlight 2.
Here is the html code that I use at the top of my search bar, you must enter this code in:
Backlight-> Languages-> US English-> Manage Language: Publisher and Search Intro (md)
You can see the result on this page:
https://phototheque.nicolaslogerot.com/ … /?q=Italie
HTML code:
<div class="hero-image">
<div class="hero-text">
<h1 style="font-size:45px"><span class="fas fa-binoculars"> </span>Images search</h1>
</div>
</div>Then the CSS (which you can modify according to the appearance of your website):
/*Display text on image in search module
================================================================*/
.hero-image {
background-image: url("https://yourwebsite.com//backlight/designer/page/image/17");
width: 110%;
margin-left: -10px;
margin-top: -20px;
height: 250px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
letter-spacing: 0.25rem;
font-weight: 700;
text-transform: uppercase;
text-rendering: optimizeLegibility;
}Nico
Thank you very much Daniel
It seems it don't work
Whao! whao! Daniel your great! thanks you very much for that but my limited knowledge means that I don't know how to call this function in the place I want... ![]()
Should I put this:
$posts = $this->dlp_get_wp_rest_response("https://yoursite.domain/backlight/api/get_album/12345");
echo "Array length: " . count($posts['album']['photos']);in a function such as:
function footer_top() {Thanks Nico
ah ok thank you, not easy all that!
This can be OK for displayed photos count of album id 343971 on any page page? But don’t work...
function scripts() {
if ($this->hasAlbum()) {
$albumId = $this->album->getId();
echo '
<script src="/backlight/modules/module-publisher/lib/js/jquery.api.js"></script>
<script>
var backlight = new Backlight()
backlight.getAlbum("343971", {
done: function footer_top() {
if ($this->hasAlbum()) {
echo '<span data-lang="fr"><p class="imagenum"><strong>'.$this->album->getNumberOfPhotos().' images dans la photothèque</strong></p></span><span data-lang="en"><p class="imagenum"><strong>'.$this->album->getNumberOfPhotos().' images in the stock photo collection</strong></p></span>';
}
return true;
},
})
</script>
';
}
return false;
}Hum interesting
but if you put album reference number like documentation it send an error:
Example:
backlight.getAlbum('. $albumId .', {By:
backlight.getAlbum('12345', {I have find Ajax_item_options.php in module-cart>application>js who contain this code:
$purchaseOption = '<fieldset>' . $LINE_END;
$purchaseOption .= '<input type="hidden" name="on' . $count . '" value="' . $attribute['title'] . '">' . $LINE_END;
$purchaseOption .= '<label for="os' . $count . '">' . $attribute['title'] . ': </label>' . $LINE_END;
if (count($attribute['options']) == 1) {
foreach ($attribute['options'] as $option) {
$purchaseOption .= '<span class="text_option">'.$option['title'];
$purchaseOption .= '</span>';
$purchaseOption .= '<input type="hidden" name="os' . $count . '" id="os' . $count . '" value="'.str_replace('"', '"', $option['title']).'">' . $LINE_END;
}
} else {
$purchaseOption .= '<select name="os' . $count . '" id="os' . $count . '">' . $LINE_END;
foreach ($attribute['options'] as $option) {
$purchaseOption .= '<option value="' . str_replace('"', '"', $option['title']) . '"';
if ($item != null && isset($item->options[$attribute['title']]) && $item->options[$attribute['title']] == $option['title']) {
$purchaseOption .= ' selected';
}
$purchaseOption .= '>' . $option['title'];
$purchaseOption . '</option>' . $LINE_END;
}
$purchaseOption .= '</select>' . $LINE_END;
}
$purchaseOption .= '</fieldset>' . $LINE_END;
return $purchaseOption;
}Because of this with the web inspector:
But nothing happens
Nico
No just the value « 6 mois » without percentage
Anyone?
![]()
Thank you very much Matthew
Hello,
I would like to count the number of images on a specific page on a separate page that does not contain an album.
I know the php code which allows me to count the number of images presented in this album but can't seem to call the function on a separate page:
function footer_top()
{
//echo 'style: '.$this->style.'<br/>';
//echo 'path: '.$this->path.'<br/>';
if ($this->hasAlbum())
{
echo '<span data-lang="fr"><p class="imagenum"><strong>'.$this->album->getNumberOfPhotos().' images dans la photothèque</strong></p></span><span data-lang="en"><p class="imagenum"><strong>'.$this->album->getNumberOfPhotos().' images in the stock photo collection</strong></p></span>';
}
return true;
}Does anyone have a solution?
thank you in advance
Nico
Thanks Rod, but it seems we can make a line break in LUA by using "\n" or "\r"
But it don’t work or I forget something
Amazing Daniel thank you very much it works great!
One last question, is it possible to do a Carriage return?
So for recap:
Dimensions: 5658 x 6880 px | 47,9 x 58,3 cm | 18,9 x 22,9 inches | 300dpi
--> 5658/300 = 18,86 inches
--> 18,86 x 2,54 = 47,9 cm
should it work?
Native dimensions: {CroppedWidth} x {CroppedHeight}px | ({CroppedWidth}/300)*2.54 x ({CroppedHeight}/300)*2.54 cm | {CroppedWidth}/300 x {CroppedHeight}/300 inches | 300dpi
Hello,
Currently on the photo legend in the viewer, I display the pixel dimensions of the photos like this:
"Dimensions: 5658 x 6880 px"
On the other hand is there a means/a method allowing to make an automatic calculation to display the resulting size at 300dpi in this way?:
"Dimensions: 5658 x 6880 px | 47,9 x 58,3 cm | 18,9 x 22,9 inches | 300dpi"
thank you in advance
Nico
Hi Ben,
Firstly, thank you very much for the fix, it seems that now everything is working perfectly!
And for the diagnosis, I looked everywhere where the error came from, thinking that it was due to my installation and came across this file. I am on Backlight since version 1, never used CE2.
Again thank you for your responsiveness and the update, it's perfect, a great team always listening!
Nico
thank you Rod, that reassures me that the error would not only come from my installation.
what happens when you are logged in to the admin and enter this address?:
https://www.yourwebsite.com/backlight/c … iagnostics
« /cart/admin/diagnostics »
with me it returns an error:
Something went wrong
Invalid argument supplied for foreach() in diagnostics.php on line 215
(maybe it has nothing to do!)
Thanks
Nico
Hummm interesting, have to try that. I have test with Chrome and Safari but not with Firefox...
Thanks Rod, I’ll try that and post result
Thanks Rod,
That's it:
French --> 1
English --> 2
I also saw this in phpadmin> Admin-Master> Language and there is a language ID column
Unfortunately, whatever I put, Cart definitely doesn't want to translate!
I tried removing languages and republishing new ones, I also tried to deactivate PHPlugins in the advanced settings of the templates .... while emptying the browser cache and using the Backlight admin ... and much more but nothing helps
Nico
Hi,
In Admin > Setting > Show advanced Settings > Miscellaneous > Cart Language
what to put? "en" or "fr", the reference language in database 1 or 2...
However I register here nothing changes
Thanks
Nico