Yii2 Advanced Template Calendar Widget: Display events from database - php

I'm using yii2-fullcalendar widget and I used thiagotalma's post on github as a guide for the installation of the calendar widget. Below is the code that I've used to display the calendar on the page:
<?= \talma\widgets\FullCalendar::widget([
'googleCalendar' => true, // If the plugin displays a Google Calendar. Default false
'loading' => 'Carregando...', // Text for loading alert. Default 'Loading...'
'config' => [
// put your options and callbacks here
// see http://arshaw.com/fullcalendar/docs/
'lang' => 'en-ca', // optional, if empty get app language
],
]); ?>
and the above code displays the calendar on the web page. Now, I want to display the events from database but I don't have any idea how to do it. Can anyone help me regarding this matter? Thanks in advance.

You might want to look into my calendar view widget, looks like it's bang on. Takes data from your model and puts them into a responsive calendar.
I am the author btw. Should be simple enough if you read through the readme, it's step by step.

Related

Get full rendered Wordpress page with WPML via REST API

I've made a Laravel-Wordpress connection for a project. For this connection, I use the Worpdress REST API.
I'm able to get specific pages from Laravel with the header and footer from Wordpress via API (for a uniform look) and other pages comes completely from Wordpress. Big benefit is, that Wordpress pages can be edited with the pretty user-friendly Wordpress backend while other pages can be custom coded in Laravel.
To achieve this, I have added some new API endpoints to retrieve the rendered header / footer and a complete page:
add_action('rest_api_init', function () {
// add 'rendered_page' member with complete HTML for requested page
register_rest_field(
'page',
'content',
array(
'get_callback' => 'by_render_page_content',
'update_callback' => null,
'schema' => null,
)
);
// add new endpoint for getting header and footer
register_rest_route('eeg/v1', '/headerandfooter', array(
'methods' => 'GET,POST',
'callback' => 'get_page_header_and_footer',
));
});
The callbacks look like this: (i.e. for the complete page)
if (isset($request['language'])) {
do_action('wpml_switch_language', $request['language']);
}
$file = THEME_DIR . '/single.php';
ob_start();
include $file;
return ob_get_clean();
As you can see, I'm checking for a language parameter and set the current language of the WPML plugin with wpml_switch_language hook.
This seems to work 'a little bit'. So, for example, the language switcher shows the correct current language.
The problem is, in the main menu: All links are showing to default language. For example if currently selected language is english, the links should look like mydomain.com/en/requestedpage. But all links go to the default mydomain.com/requestedpage. Also the <html lang> parameter is set to the default language, not to the requested. And also the <link hreflang> tags from WPML are missing.
If I access the page via the Wordpress Frontend (which is hosted at a subdomain), everything is working correctly.
So I think, I have to set the requested language somewhere else or have to call some WPML 'prepare' hooks or something like that, to make this work. Maybe also the include './single.php'; is not the right way to do this.
Any hint is welcome.
I could fix it by myself.
The solution was to create a translated menu with WPML.
In Wordpress frontend, the links in the menus are localized also without an extra translated menu. But for this scenario with the REST API, a translated menu is necessary.

WP Full Calendar Changing the Event URL

I am using WP Full Calendar and Event Manager Plugin for Wordpress.
The calendar currently links to the single event url, however I want it to link to the #_BOOKINGSLINK placeholder (the admin page for management).
Is this possible to do?
I found code for the function file that removes the URL, but I am unsure of how to code the placeholder with PHP, as I am a beginner.
Is anyone able to assist me? Many thanks in advance.
Code That Removes URL from calendar:
function my_fc_filter( $events ){
foreach($events as $key => $event){
unset($events[$key]['url']);
}
return $events;
}
add_filter('wpfc_events','my_fc_filter');

How to change Sign up page design in Moodle

I am new to moodle and i am using 2.9. I have a separate design for Signup page (HTML5 & CSS). How to integrate this page ?
I know the process of changing the default Login page like this
In config.php of my theme
'login' => array(
'file' => 'login.php',
'regions' => array(),
'options' => array('langmenu'=>true),
),
Where my Custom login page is login.php which is placed in my layout folder. So in this way i can takeover Login page design with my new design.
But i don't see any signup array in config page for Registration. So anyone can tell me how to do this change ?
Edit - I have checked this file moodle2\login\index_form.html I can see the signup design. But my issue is that file index_form.html has Moodle core CSS if i add my CSS there it will conflict also i dont know how to load the CSS from my theme folder to index_form.html.
Can anyone guide me ?
I already checked Moodle.org forum but not able to find the process.
Thanks In Advance
Lorry
Further to what #davosmith mentioned, you can actually use the existing auth/email plugin as a base for your plugin, So:
Copy auth/email and rename it to whatever you want, for example auth/foo. And rename all other instances of "email" to "foo".
Copy the login/signup_form.php to your plugin directory
in your auth/foo/auth.php file, add a function:
function signup_form() {
global $CFG;
require_once($CFG->dirroot.'/auth/foo/signup_form.php');
return new login_signup_form(null, null, 'post', '',
array('autocomplete'=>'on'));
}
Modify the auth/foo/signup_form.php to whatever you want
Hiii,
I'm one of the Moodler who working with Moodle.
to edit the signup page go at the following location and open the signup.php file.
./moodle/login/signup.php
in that file you can see at bottom of the page three lines.
...
echo $OUTPUT->header();
$mform_signup->display();
echo $OUTPUT->footer();
in which $mform signup->display(); create a form yu can comment and write HTML for your sign up form.
But make sure about the Action URL and the validations.
$mform is the object that create form and its class file is signup_form.php.
Hope it helpful for you ... Good Luck ['}
If you are wanting to avoid making changes to the core code in Moodle (which should almost always be what you want), then you can create a new signup form from scratch by first creating a new authentication plugin (in auth/NAMEOFPLUGIN).
When you create the authentication plugin, you should make sure that the 'can_signup' function returns true, that the 'user_signup' function does whatever processing is needed to create the new user account and that the 'signup_form' function returns a custom Moodle form that contains the fields you want.
It is possible to further customise this form by outputting custom HTML elements (using $mform->addElement('html', 'The HTML to output'); ). I would not advise completely abandoning the Moodle form (i.e. to replace it with hand-coded custom elements), as that will not be compatible with the signup code in login/signup.php (as well as losing the validation rules that are supported by the forms library).

TYPO3 TCA, hide tab in translated item

In my Extension I create several tabs for the backend with --div--, the code looks something like this:
'types' => array(
'0' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1,--div--;My Tab, title, category,
),
While there is an easy way to hide a single field in the translated item with: 'displayCond' => 'FIELD:sys_language_uid:=:0',, I have no idea how to hide a whole tab.
Does anybody know how I have to write the 'types' array to hide "My Tab" in the translation records? Thank you in advance.
Edit (Solution):
Using config as stated in the answer is possible, but there is another way I discovered by accident: If you hide all fields that are associated with a tab with 'displayCond' => 'FIELD:sys_language_uid:=:0', the tabs will also be hidden.
I think you may need to use tsconfig.
Please check the section: "New content element wizard (mod.wizards.newContentElement)" in this link: http://typo3.org/documentation/document-library/core-documentation/doc_core_tsconfig/4.3.2/view/1/5/

Drupal node 2-page content split

My employer requires certain pages on the website have a two page feature.
What this means is that some default content show up on the node_view page as normal but the second part should show up when a link is clicked.
This will be easy if I could do this across multiple nodes but the requirement is for all the data to be stored in one node but displayed across two pages.
I hacked together the following code:
function mymodule_node_view($node, $view_mode, $langcode){
$path = current_path();
$path_alias = drupal_lookup_path('alias',$path);
$links = array( 'test' => array('title'=>'my_link', 'query'=>'', 'href'=>"{$path_alias}/nextpage") );
$node->content['my_module'] = array(
'#theme' => 'links__node__mymodule',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
That creates a hyperlink called my_link across the top of my content area - which is great.
The problem starts when I click the hyperlink. Supposing I am on http://example.org/homepage and I click the hyperlink, I expect to be redirected to http://example.org/homepage/nextpage. Also, I still want to maintain the view and edit tabs of the actual node I was on. However, Drupal correctly gives me a "page not found" error.
What's interesting is if I used http://example.org/node/1 and visited http://example.org/node/1/nextpage, I don't get the issues I described above but the url is less descriptive.
To solve this problem, I am sure I have to extend hook_menu but I don't know how to account for any number of taxonomy terms leading up to the actual node title. So, I can't predict how many % I will need before the node title and then my /nextpage. However, I want /nextpage to still have the view and edit tabs of it's parent page.
This is all unexplored territory for me.
Update
I found the following function which does a great job of returning the entire node path complete with taxonomies:
$path = current_path();
$path_alias = drupal_lookup_path('alias',$path);
What I don't know is how to take advantage of this in hook_menu to dynamically create /nextpage for my nodes.
Please remember, I don't really want /nextpage to be entirely independent of the original and actual Drupal node. When on /nextpage I want to be able to have access to the view, edit etc tabs of the node.
So, /nextpage effectively is just an extension of a Drupal node page.
There is a quick way to do that. Using views module.
In the fields section choose the field you wanna view. And in the arguments add the nid.
Then add the link to the node view you already created.
The final result http://mysite/views-page/[nid]
Hope this helps... Muhammad.
I would check the node_menu() function to get some reference on how it's implemented.
Not sure on your taxonomy requirements so this might be insufficient but I'll go with what I understand.
But off the top of my head I'd go for something like:
function mymodule_menu() {
$items['node/%node/nextpage'] = array(
'title' => 'Next page',
'type' => MENU_LOCAL_TASK, // Makes it a tab on node/%node-pages
'page callback' => 'mymodule_node_page_view', // Your page display function
'page arguments' => array(1), // First will be a node object, second will be whatever value is passed in the url
// You should rip access callback and access arguments from node_menu()
);
return $items;
}
That should do something like what you are asking for.
It is also possible, easier and definitely recommended to do this with Panels/Pages (see also Chaos Tools) or arguably Views as they are quite capable of all this and generally a better way to work with Drupal's strengths than custom code.
Updated
To clarify I've simplified the menu hook and you should be able to use the below page view function. I still believe you would make a better solution using Panels and overriding node_view and such.
The MENU_LOCAL_TASK part in the menu hook should turn this into another tab along with View and Edit.
function mymodule_node_page_view($node) {
die("It works: ".$node->title);
}
Hope that's more helpful.

Categories