How to set template path in redux framework? - wordpress

I need to customize panel templates in my theme, which I use redux. I copied ReduxCore->templates->panel folder into mythemefolder->redux-framework->ReduxCore->templates->panel.
For some plugins, this overrides the templates from plugin, but not the case here, I found that I need to manually tell redux to look for the templates elsewhere other than default folder inside plugin. but I'm not sure how to do it.
I tried adding 'templates_path' => dirname(__FILE__).'/templates/panel', inside redux config file, but it just throws an error with Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW)
then I found in redux docx,(https://docs.reduxframework.com/core/advanced/filter-hooks/) that there's another way to put redux/{opt_name}/panel/templates_path, but it has no reference how, or where to put this code.
can anyone help me out please?

https://docs.redux.io/guides/advanced/panel-templates.html
Redux::setArgs('opt_name', array('templates_path'=> dirname(__FILE__).'/templates/panel/'));
That SHOULD do it.

Related

problem with import bootstrap theme to ruby on rails app

I can't seem to import this bootstrap theme to my rails application.
https://github.com/puikinsh/sufee-admin-dashboard
I am trying to import this template for two days but no luck. It could be easy, but I don´t know what I´m doing wrong :(
I receive this error:
Undefined variable: "$border-color".
Undefined mixin ....
So I have got a problem with variables and mixins at the first time. I tried another template and it works, so I really don´t know what to try next.
Any hint or idea about how to solve this problem would be really appreciated.
Thanks
Porting a template into your Rails application is not hard if you break it down into several imprortant steps:
Import styles. From what I can see, your template is using sass along with plain css style files. You can pick one of those and copy the files into your /app/assets/stylesheets folder and importing them in your application.sass. The Undefined variable: "$border-color". points you towards missing variables.scss, which contains all the color variables for your template.
See if your template is using any third-party libraries or frameworks. In this particular example, there is a list of them in the repo's "Built With" section of the readme. Go through every single one of them and find gem versions of those libraries and add them to your Gemfile.
Copy non third-party Javascript files into your app/assets/javascripts. Require them in pagedown.coffee.erb along with third-party modules. Be sure to keep non third-party code below other modules to preserve functionality of code that relies on those modules.
Trim HTML templates into views. Figure out what part of your layout should be preserved for every page and put it into your layout view, break down the rest into controller-specific views.
There can be a lot of problems, but in general, just try to analyze the errors being thrown and solve them one by one.

Drupal 8 add javascript and pass data in a hook with custom module

I am building a custom module with Drupal 8. One of the requirements of the module is that it sets up a javascript file based on the configuration settings, which the user of the module sets up in module configuration.
The javascript which needs to be added to the page depends on the configuration settings. Hence I can not add it using Libraries as mentioned in this article: Adding assets to Drupal module.
I first implemented it using a block. I use Twig templates to pass the configuration variables in PHP to the twig file, and in the twig file, I have a tag to add the javascript based on the config variables. Refer Using twig templates.
The problem with this approach is that user needs to add the block on the page, and there is no UI facing element on that block. I also find it very messy.
Is there a cleaner way to add my javascript using hook and pass variables to it? I looked around and found hook_install and hook_page_attachments. So I can add Javascript, but don't know how I can pass any php variables to it.
I am new to Drupal development. Any help with this is really appreciated.
TL;DR I need to find a way to add Javascript using Drupal hook and pass some PHP variables to it.
Use in hook_page_attachments:
$attachments['#attached']['drupalSettings']['myvar'] = $myVariable;
Then in your js (I assume you already know how to attach js library):
(function ($, Drupal, drupalSettings) {
Drupal.behaviors.my_custom_behavior = {
attach: function (context, settings) {
var strings = drupalSettings.myvar;
...
}
}
})(jQuery, Drupal, drupalSettings);
See nice Acquia tutorial for more examples.

Full instructions for Meteor Semantic-ui integration by a frustrated n00bie?

I wish there were better instructions for installing and getting started with Semantic-ui on Meteor....please see below.
Any improvements/feedback welcome.
I just decided to post these because of some difficulties I had getting semantic-ui to work with Meteor. I figured out the few things I was not getting from various answers across various forums:
Install via CLI: meteor add semantic:ui flemay:less-autoprefixer (You don't need to worry about LESS)
Create an empty custom.semantic.json file in /client/lib/semantic-ui/custom.semantic.json. (Note this is NOT the lib folder that is outside the client and server folders - make a new lib folder. Putting it in the original lib will cause your app to crash because jQuery hasn't been loaded
Start meteor - the custom.semantic.json file will populate and all the semantic-ui files will be added to your project in the same folder.
Edit the file custom.semantic.json to select only the definitions and themes you want
If you are happy with the default values you will need to remove .custom.semantic.json to generate Semantic UI - in all likelihood you will want to delete this file.
Save the file and it will generate Semantic UI
It hasn't been an issue for me yet but it appears that if you are changing theme you still need to leave the default theme setting as true. This seemed to be causing people confusion.
I wanted to use the accordion and couldn't figure how to get it working. The HTML from the docs is very straightforward but I needed this JS to get me going:
Template.yourTemplate.rendered = function() {
$('.ui.accordion').accordion();
}
If anyone knows a better way, please jump in.
Hope this helps someone avoid the minor frustrations I had earlier today.

Create a new custom field option in redux wordpress framework

I want to create new field in redux wordpress framework using Custom fields, but I can't find any help or example using this.
i want to create a field with a switch and text field both.
Any suggestions is most appreciated.
Lead dev of Redux here.
If you want to make a new field, then you should build an extension. We've setup two repos that will help you get started.
First:
https://github.com/ReduxFramework/extension-boilerplate
This is an extension boilerplate. It will help you see how to do this.
Second, is the extension loader:
https://github.com/ReduxFramework/redux-extensions-loader
This will load the extension. You can also use it to overload any existing Redux fields.
Be VERY careful to load your Redux options in this order:
Extension Loader
Redux Options Config File
Otherwise Redux will be initialized before you run the extension hooks to overload/add new types. From there you just call your custom field type like you would any other field.
Good luck!
In order to update the answer, it's important to note that this page refers to the legacy method to load extensions.
The current method to load extensions is by adding the next line into redux config file (I guess is OK to add it at the end of the file).
Redux::setExtensions( 'OPT_NAME', 'FULL PATH' );
...from the docs:
Be sure to replace OPT_NAME with your opt_name and FULL PATH with the full path to your extension(s) location.

ASP.NET themes: How to tell if a theme name is valid before setting it as the theme of a page

I imagine this would be simple, but I can’t find an answer.
We set the theme of a page based on a query string parameter (like ?theme=theme1, etc). I just want to know if there is an easy way to tell the theme name is valid, before setting it, or catching and handling the error if it is invalid.
The error I get if the theme does not exists is:
Theme ‘theme1’ cannot be found in the application or global theme directories.
I am not sure when the exception is thrown.
All I can think of is searching the folder, but I would think there would be a simpler way.
Thanks
Check the theme against the list of theme folders; themes simply uses the folders of the name, so use Directory.Exists within System.IO.

Resources