How to configure Vimeo-Service-module in Silverstripe - php

Forgive me for my English
I am new in PHP. And I'm building a site using Silverstripe and trying to configure Vimeo-Service-module. I'd follow the steps from this link
https://github.com/r0nn1ef/Silverstripe-Vimeo-Service-module
I did everything that mentions in the article. And created a page in admin panel of VimeoGallery page type and set the parameters on Videos tab to grab the videos for display.
After created page, I visited my and clicked on video menu but then all I see is no videos returned. It is showing blank page and no any error messages.
Is that I've done anything wrong. Please guide me...
Thanks in advance.

OK, I think I see the issue here. You are calling VimeoService::setAPIKey() however accessing the method like that is deprecated in the new version (the 2.0 branch - I was incorrect in my comment when I mentioned master) of the module.
The module instead uses the Site Config in the CMS to set the API key and a few other settings.
Now just remove VimeoService::setAPIKey() from your _config.php file, run /dev/build and set the API key through the CMS.
EDIT
On line 142 of VimeoGalleryPage.php, there is a function called flushCache. Replace the code in that function with the following:
public function flushCache($persistent = true) {
parent::flushCache($persistent);
unset($this->_cachedVideos);
}
Basically, the code in the 2.0 branch for this function does not correctly extend the same named function in SiteTree.

Related

how can i send data from whmcs hook to admin module files?

i created an addon moodule in WHMCS and its working just fine!
now im trying to work and learn hooks
i have tried somethings for client side and it worked but i have problem in admin side
here is what i tried so far in hooks.php on my module directory:
add_hook('AdminAreaPage', 1, function($vars) {
$extraVariables = [];
if ($vars['filename'] == 'addonmodules') {
$extraVariables['newVariable1'] = $vars['admin_username'];
}
return $extraVariables;
});
but when i in list.php (a file in module directory) want to get the $extraVariables like below, its null !
<?php var_dump($extraVariables); ?>
what im doing wrong or whats im missing?
i simply just want to get data im creating in hook in my module files
does whmcs hook variables only works and have access in tpl files?
As seen in the documentation, the answer is, yes variables are only available inside the template(s)
Response
Accepts a return of key/value pairs to be made available to the template layer as additional template variables.

Disable template caching for development in OpenCart 3

I am making changes in my theme templates in OpenCart 3. Due to template caching I have to clear cache every time under "storage/cache" directory. It is very annoying when working and previewing changes frequently during development. Please provide some solution how we can configure caching according to production and development environment.
Note: I have already searched for solutions online but there is no solution related to template caching. Solutions are available to disable image caching but "Image Caching" and "Template Caching" are different features provided in Opencart.
You might need to upgrade to a more recent version of OpenCart3 - the first one (3.0.0.0) didn't have a way of doing this in the GUI.
More recent versions, such as 3.0.2.0, have a gear on the admin dashboard. Click the gear and you get options to disable caching.
Another way to do this:
Open to system\library\template\Twig\Cache\Filesystem.php, find following lines of code
public function load($key)
{
if (file_exists($key)) {
#include_once $key;
}
}
Comment out as in the following code:
public function load($key)
{
// if (file_exists($key)) {
// #include_once $key;
// }
}
This will remove the template cache of the twig and recreate every time, once development is over you have to remove the comment.
You can also do this from CODE directly if you have the access. Go to this file path below via ftp or cPanel:
system\library\template\Twig\Environment.php
Find
$this->debug = (bool) $options['debug'];
Replace:
$this->debug = (bool) true;
Opencart Version 3.0.2.0
I was having same problem, try working in theme editor or the actual raw twig file, after an hour or two i tried this it worked.
Delete the changes in theme editor and got back editing actual twig file
my screen shot
I think you edit the template as the path: Design->Theme Editor before.
Clear all of the date in the oc_theme data table of your database.
Scott's answer is best but in case it's not available due to version or you want to disable it programmatically you can do this anywhere before the twig is rendered:
$this->config->set('template_cache', false);
in OC 3.0.3.6, if you have some twig extension, like twig managers, after changes maded you should select that extention in modifications and refresh push button on top right corner.
P.S. loose whole day to find this, hope it helps someone
This is similar to Scott's answer but just on the database/backend. In case you can't rely on the UI and can only access the DB (like me, I'm messing up with the UI) it's on settings table search for 'developer_theme' key and set it to false or 0.
UPDATE `oc_setting` SET `value` = '0' WHERE `oc_setting`.`key` = 'developer_theme';

How to call TYPO3 plugin when normal page renders

Well, I am developing a plugin a and I need to display some stuff from my plugin when TYPO3 page load.
Is there some function how to hook action, like in WordPress when page loads than plugin will execute some controller method? Then this controller will produce some output a HTML, which I would like to dispaly in frontend page. Specially I would like display custom script in the head. So the script should be like this <head>...<script>my content</script>...</head>
Ok, what you probably want to do is to develop a so-called TYPO3 extension - that's what plugins/add-ons are called in TYPO3 (which is the term you will likely find google results for).
To get started fast you can try the TYPO3 extension builder (https://docs.typo3.org/typo3cms/extensions/extension_builder/) - which can generate a skeleton extension for you.
For more information you can also have a look at https://docs.typo3.org/typo3cms/CoreApiReference/latest/ExtensionArchitecture/Index.html which explains the concepts in far more detail.
Additional information is available in https://docs.typo3.org/typo3cms/ExtbaseFluidBook/Index.html
in TYPO3 there is something named plugins, but you should differ to the meaning in other context.
first TYPO3 is a CMS which content is structured in a hierarchical tree of pages. These pages are the basis for navigation. and each page contains individual contentelmenents (CE).
As Susi already told: add ons to TYPO3 are in general 'extensions' which could extend(!) the functinality of TYPO3 in different ways. one way is the definition of (TYPO3-)Plugins. These are special ContentElements which enable to show special information.
While normal CEs have all the information what to show in the record (e.g. Text & Image), plugins can be more flexible.
typical examples are: show a list of records OR one record in detail.
These Plugins can be controlled with typoscript or the plugin-CE could have additional fields to hold information what to display.
For detailed information how a plugin is defined consult the links given by Susi.
And be aware: for security reasons it is not possible to just execute a plain PHP file to echo any output. You need to register your plugin using the API, build your output as string and return the generated HTML as string to the calling function. For beginners the ExtensionBuilder will help you to generate a well formed extension which uses the API to register and output your data.
OK guys, thanks for your answers, but it was not very concrete. I found this solution, is not the best one, but it works! If anybody has better please share.
At first, you have to make a file for the class which will be called from the hook at location /your-plugin-name/Classes/class.tx_contenthook.php. Filename have to have this pattern class.tx_yourname.php Inside we will have a code with one method which will be called by the hook.
class tx_contenthook {
function displayContent(&$params, &$that){
//content of page from param
$content = $params['pObj']->content;
//your content
$inject = '4747474747';
// inject content on
$content = str_replace('</body>', $inject. '</body>', $content);
// save
$params['pObj']->content = $content;
}
}
And next, we have to call it on the hook. So Let's go to /your-plugin-name/ext_localconf.php and add there these two lines, which makes a magic and handles also caching.
// hook is called after caching
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] = 'EXT:' . $_EXTKEY . '/Classes/class.tx_contenthook.php:&tx_contenthook->displayContent';
// hook is called before caching
$TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][] = 'EXT:'. $_EXTKEY .'/Classes/class.tx_contenthook.php:&tx_contenthook->displayContent';
I hope this will help those who struggling with typo3.

Opencart 2: Events not triggered

I'm using opencart version 2.1.0.1 and trying to use the new script notification system.
Please note that I have simply installed the original version. Nothing extra added or modified.
Following the tutorial found here: http://isenselabs.com/posts/opencart2-event-system-tutorial
I managed to create a new module and install it successfully.
I can confirm from the database that it has registered the events that I want to trigger.
To give you a better picture I have created these files:
admin/controller/module/testo.php
admin/view/template/module.testo.tpl
admin/language/english/module/testo.php
catalog/controller/module/testo.php
Now although the admin events are triggered with no problem the Catalog (fronted) Order Events never fire.
On admin/controller/module/testo.php function install I have the following call:
$this->model_extension_event->addEvent('testo', 'post.order.add', 'module/testo/on_order_add');
And according to the tutorial the function to fire should be in catalog/controller/model/testo.php
public function on_order_add($order_id) { .... }
The function simply writes the order_id to a text file, nothing tricky there.
So when I complete an order the function never runs.
I have tried most Order Notification Hooks with no luck.
Am I missing something?
Is there something I'm not understanding?
Please help since there is absolutely no documentation and I'm on a dead end (for the time)
You are calling it incorrectly, your catalog file path must be
catalog/controller/module/testo.php
not
catalog/controller/model/testo.php
because your trigger is
$this->model_extension_event->addEvent('testo', 'post.order.add', 'module/testo/on_order_add');
it's meaning -> Opencart will search catalog/controller/module/testo.php file and will call it's on_order_add() function when 'post.order.add' trigger will execute (because trigger in catalog side it will use catalog/* or else it will use admin/*), 'testo' is just name part noting important.
In your case it's searching correctly but you don't have any file on this path because you added file to
catalog/controller/model/testo.php
so change your folder structure -> model to module or change your trigger from module to model.
Are you sure writing to text file is working?
because i also tried to get post.order.add event on my Opencart 2.0.3.1, and its working fine.
try writing to log file
<?php
class ControllerModuleTesto extends Controller
{
public function on_order_add($order_id)
{
$this->log->write("Order Id " . $order_id . " was created.");
}
}
?>
and check logs at backend->Tools->Error Logs

How to add comments to each forum post in yii, using bbii forum module and comments-module

I am using Yii bbii forum module and it works fine. But now I want to add comments-module so every forum post could be seperately commented.
At the begining it might look:
I followed instruction what is here, but I can't make it work :(
And why I even need to include this file, if I want to add just comment?
When I added the same widget to user page (just for testing) - I got "This item cann't be commentable" and it's fine because probably I don't have correct configuration in main.php.
Difference between widget in user model view and forum view is data passed in it.
Here:
public function actionPostComment()
{
if(isset($_POST['Comment']) && Yii::app()->request->isAjaxRequest)
{
$comment = new Comment();
$comment->attributes = $_POST['Comment'];
var_dump($comment);
var_dump returned this when tried to submit comment in forum, and here in user view page.
And probably it is not even possible to combine these to modules? I'm really new in Yii.
Updated:
Basically what I have done is:
exstracted comment module (under protected->modules)
in main.php (under protected->config) added all cofiguration in modules array:
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => false,
'useCaptcha' => false,
.......
and in view file _post.php added following:
<?php $this->widget('comments.widgets.ECommentsListWidget', array(
'model' => $data,
));
and var_dump($data) gives this (when this is called in controller where post is reseaved).
An error message was given here:
include(BbiiPost.php): failed to open stream: No such file or directory
You said that the Bbii was working with Yii and it broke when you tried to add comments.
The links to your var_dump files are broken, but I did try to read them ;)
It looks like the comments module is interfering with the POST path so that when the form submission comes in it is in a different path from the root which is confusing the YiiBase's autoloader.
You could try explicitly adding the path to BbiiPost.php to the autoloader's search path, or finding where the include("BbiiPost.php") line is and changing it to an absolute path.
Another possibility is that the forum page you are on has links to add comments but the page routing has not been taken from the route. So it might be that the POST link to the comments is actually at /forum/123/comment/add instead of just /comment/add. So when the form is submitted it is trying to the comments/add controller/action but finding that it is in /forum/view and getting confused about the paths to the include files.
I have generally found that the instructions on the Yii (v1) [v2 docs are much better] site for these modules is flaky at best. Quite often the source download link on the page points to an old buggy version of the code as the project has usually moved somewhere else. You generally need to have a pretty good PHP/Yii knowledge to debug these user-submitted modules and get them working.

Categories