Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable flipcss for the backend only #7

Closed
ahmeddhifi opened this issue May 2, 2019 · 2 comments
Closed

How to disable flipcss for the backend only #7

ahmeddhifi opened this issue May 2, 2019 · 2 comments

Comments

@ahmeddhifi
Copy link

Hello,
It'll be nice to have the option to disable the flipcss just for the backend.
Most users prefer to user the backend in english while the frontend is localised.
THanks

@TheServat
Copy link
Contributor

flipcss is a twig filter if you don't want back-end in rtl mode simply disable or uninstall plugin.
you can write a simple plugin for flipcss twig filter with using this class https://github.com/octoberfa/oc-persian/blob/master/classes/CssFlipper.php and add this code in your plugin.php file

class Plugin extends PluginBase
{
    public function register()
    {
        $this->registerMarkupTags();
    }
    public function registerMarkupTags()
    {
        MarkupManager::instance()->registerCallback(function ($manager) {
            $manager->registerFilters([
                'flipCss' => [$this, 'flipCss'],
            ]);
        });
    }

    /**
     * Twig Markup Filter 'flipCss'
     * @param $paths
     * @param bool $force
     * @return array|string
     */
    public function flipCss($paths)
    {
        if (!is_array($paths)) {
            $paths = [$paths];
        }
        $rPaths = [];
        foreach ($paths as $path) {
            $assetPath = $path;
            if (File::exists(dirname($assetPath) . '/' . File::name($assetPath) . '.rtl.' . File::extension($assetPath))) {
                $newPath = dirname($assetPath) . '.rtl.' . File::extension($assetPath);
            } else {
                $newPath = CssFlipper::flipCss($assetPath, true);
            }
            $rPaths[] = $newPath;
        }
        return $rPaths;
    }
}

@ahmeddhifi
Copy link
Author

ahmeddhifi commented Jun 3, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants