Silverstripe: Top.PageControllerFunction not displaying - php

I am using the Silverstripe Twitter module. It has a page controller function called LatestTweets($value) Which obviously displays the latest tweets.
When I add the Latest Tweets function to the Page.ss template. The tweets display. Everything works fine.
I am also using shaedawson's blocks module. I have a 'grid' block. The Grid Block has a template (Grid.ss) In the Templates Folder (templates/). When I add $Top.LatestTweets(3) to the Grid Template, the tweets do not appear.
Can anyone explain why this is happening?

It works on any page controller, because the module tractorcow/silverstripe-twitter enables extension TwitterExtension on the Page_Controller in its configuration.
Blocks in sheadawson/silverstripe-blocks module are rendered with SiteTree context (the top scope) and your LatestTweets() function is not available.
So, the only remedy is to enable the TwitterExtension on your Page.

I figured this out. The reason why the "Latest Tweets" function was not appearing on my template, was because I had to extend Block_Controller
I added the following to my 'extension.yml' file:
Block_Controller:
extensions:
- TwitterExtension
I would like to be able to 'include' the "Twitter Feed" template in my Grid Template. However this works and will do for now.

Related

Moving a block (view) into a different region programmatically (Drupal 7)

I use the Commerce Kickstart Distribution of Drupal 7. I want to have the searchbar assigned to a different region on the frontpage than on all other sites in my theme. I used the approach shown here: http://saw.tl/drupal/programmatically-manage-drupal-blocks.html
function mytheme_hook_block_info_alter(&$blocks, $theme, $code_blocks)
{
if(drupal_is_front_page()) {
$blocks['views]['-exp-display_products-page']['region'] = "branding";
}
}
This is the function in my template.php. I know that the search bar is created using the views module and is not a "default block".
The name shown in the Block menu for the search bar is Exposed form: display_products-page, the module name and machine name I choosed following this tutorial http://drupalchamp.org/node/166
However, it does not work at all. I do not get any errors or warnings, the block just stays in is default region when I load the front page.
You can use Context module to add blocks to different regions depending on some criteria:
https://www.drupal.org/project/context
Very powerful and easy to use module so I'm advising it.
And if you prefer doing it form code you could grab block's content and print it from template directly, depending on detected page. Something like:
$block = module_invoke('views', 'block_view', 'block_machine_name');
print render($block);
Of course you would execute it conditionally...

Visual composer Masonry grid doesn't load

I'm using [insert_php] plugin in Wordpress and I have inserted php function in it.If I set the block with the function before the the masonry grid it doesn't load.
If I move the block with the function after the grid it works well.
In console log is appearing an alert:
Syntax error, unrecognized expression: {'status':'Nothing found'}
How can I sole that?
Grid before php block
Block php before the grid
What you need to do is create a page template. This page template can be used to create PHP for your page to load, and you can even use
<?php echo do_shortcode('[shortcode]'); ?>
To create a template just copy your page.php into a new file called tpl_test.php.
Then make sure to have this in the very first line:
`<?php
/*
Template Name: Test Template
*/
?>`
Then, a small window will show up on the back-end of WordPress when you edit the page. In the right hand column you need to select the page template for the page you just created, and update the page. then, any code you put in the custom Page Template will display correctly on your WordPress site. Also, make sure <?php the_content() ?> is below your grid you are trying to output.

Wordpress Get URL Footer File

I need to access the footer inside a wordpress theme via a url. Ideally it would just render the footer data and nothing else, alternative suggestions welcomed though.
To add some context, the data will be fetched through the url and a script will read the markup. This data will then be cached and available through Magento where it is needed to be displayed..
Is there a url path that will display it or should I make a new page that can be called via the base-url+the-page-name???
There's nothing built in to do that. You could use the AJAX API in your theme or a plugin and accomplish it.
You hook into an action that gets sent as a URL or POST data parameter and then make a request to yoursite.com/path/to/wordpress/wp-admin/admin-ajax.php.
<?php
add_action('wp_ajax_so20495429_display_footer', 'so20495429_display_footer');
add_action('wp_ajax_nopriv_so20495429_display_footer', 'so20495429_display_footer');
function so20495429_display_footer()
{
get_footer('ajax');
}
This will work for all users, logged in or not, despite the wp-admin URL. Here is code above wrapped up in a plugin.
what you can do is make a wordpress custom page template.
If you dont know how heres a little tutorial : http://www.expand2web.com/blog/custom-page-template-wordpress/
Now you want the custom page template to only load the footer (add the html, head and body opening tags yourself)
if you create a new page with your page template seletced it will only output the footer.
Hope you can get it to work
Greetings
merijn
What about $footer_url=get_template_directory_uri().'/footer.php'; ?

Call Module in tpl file in prestashop

I want to use search module in my header.tpl file .
In that i used this code
{include file='./modules/blocksearch/blocksearch.tpl'}
But it's not working and by using this code my page gets blank.
Thanks in advance
Here you will find what you are looking for
http://www.ecartservice.net/prestashop-articles/1-4-plugins-revisited-part-1/
It is a great and easy way to call modules directly in template files, without the use of hooks. I tested it in both Prestashop 1.4 and 1.5 and it works.
For Prestashop 1.5, you will need to create 2 extra files in the "override" folder, as described in the link above:
Plugin.php in /override/classes/
FrontController.php in /override/classes/controller/
Then, you will be able to use in the template files the following code:
{plugin module='editorial' hook='displayHome'}
You need to use the hook's name (displayHome) and NOT the alias (home).
You cannot include a module template like this because the PHP code of te module is not called and the template needs it to set some Smarty variables.
The best you can do is to hook the blocksearch module to your header. Here we go :
Navigate to "admin > modules > positions"
Click on "Transplant a module" button
Select "Quick Search Block" for "Module"
Select ""Header of pages / displayHeader" for "Hook into"
Click "Save"
The "Quick Search module" is now hooked to your header.

Can't find Joomla pagination template

I'm going crazy with this one. I am trying to change a little bit the pagination style and layout in Joomla. So, I found this file: libraries\joomla\html\pagination.php but I know that pagination is overridden by this file: templates\gk_yourshop\html\pagination.php. Yet, if I modify something in gk_yourshop\html\pagination.php, I can't see the change in the pages. Does joomla cache templates and I have to re-load them (like phpBB)?. I don't understand.
I tried to check if writePagesLinks is called from joomla\html\pagination.php with this:
function getPagesLinks()
{
echo "test";
global $mainframe;
and I can't see the message. I also did this in the other pagination.php file and it's just like I can delete them and it doesn't matter. Can you help me? Thanks!
Looks like I changed it here some time ago:
\libraries\joomla\html\pagination.php
But, that is system file, so i just make a "hotfix" of it.
In Joomla 3.x you can create pagination override from Extensions > Templates > Default Template > Create Overrides > Layouts > Pagination.
The override files are created in "Default Template" "html\layouts\joomla\pagination" folder.
You can edit the override files as per your needs.
Where are you getting WritePageLinks from? That's not one of the supported methods.
http://docs.joomla.org/Understanding_Output_Overrides#Pagination_Links_Overrides
There are four functions that can be used:
pagination_list_footer
This function is responsible for showing the select list for the
number of items to display per page.
pagination_list_render
This function is responsible for showing the list of page number links
as well at the Start, End, Previous and Next links.
pagination_item_active
This function displays the links to other page numbers other than the
"current" page.
pagination_item_inactive
This function displays the current page number, usually not
hyperlinked.
[edit]
You may also want to look at Protostar as an example.

Categories