Coder Social home page Coder Social logo

voyager-themes's Introduction

Voyager Themes

This is a theme hook for voyager and the hook system

Voyager Themes Admin Page

Installing the hook

You can use the artisan command below to install this hook

php artisan hook:install voyager-themes

Adding Themes

The voyager-themes hook will look inside of the resources/themes folder for any folder that has a .json file inside of it with the same name. (You can change the theme folder location in the config)

As an example if you have a folder called sample-theme and inside that folder you have another file called sample-theme.json with the following contents:

{
    "name": "Sample Theme",
    "version": "1.0"
}

Voyager Themes will detect this as a new theme. You can also include a sample screenshot of your theme, which would be sample-theme.jpg (800x500px) for best results

In fact, you can checkout the sample-theme repo here: https://github.com/thedevdojo/sample-theme

You can activate this theme inside of Voyager and then when you want to tell your application which view to load you can use:

return view('theme::welcome')

This will then look in the current active theme folder for a new view called welcome.blade.php :D

Theme Configs

You may choose to publish a config to your project by running:

php artisan vendor:publish

You will want to publish the voyager-themes-config, and you will now see a new config located at config/themes.php, which will look like the following:

<?php

return [

    'themes_folder' => resource_path('views/themes'),
    'publish_assets' => true

];

Now, you can choose an alternate location for your themes folder. By default this will be put into the resources/views folder; however, you can change that to any location you would like.

Additionally, you can set publish_assets to true or false, if it is set to true anytime the themes directory is scanned it will publish the assets folder in your theme to the public folder inside a new themes folder. Set this to false and this will no longer happen.

Theme Options

You can also easily add a number of options by including another file in the theme folder called options.blade.php

Voyager Theme Options Page

Inside the options.blade.php file you can now add a new field as simple as:

{!! theme_field('text', 'title') !!}

This will now add a new text field and store it with a key of title. So, now if you wanted to reference this value anywhere in your theme files you can simple echo it out like so:

{{ theme('title') }}

Couldn't be easier, right!

Take a look at all the following explanation of the theme_field function.

The theme_field() function

The theme_field() function can be used to display fields in our theme options page. Take a look at the function DEFINITION, EXAMPLE, EXPLANATION, and TYPES OF FIELDS below:

DEFINITION:

theme_field(
    $type, 
    $key,
    $title = '',
    $content = '', 
    $details = '', 
    $placeholder = '', 
    $required = 1)

EXAMPLE of a textbox asking for headline:

{!! theme_field(
        'text', 
        'headline', 
        'My Aweseome Headline', 
        '{}', 
        'Add your Headline here', 
        0) 
 !!}

Only the first 2 are arguments are required

{!! theme_field('text', 'headline') !!}

EXPLANATION:

$type
    This is the type of field you want to display, you can
    take a look at all the fields from the TYPES OF FIELDS
    section below.
 $key
    This is the key you want to create to reference the
    field in your theme.
 $title
    This is the title or the label above the field
  $content 
    The current contents or value of the field, if the field
    has already been created in the db, the value in the
    database will be used instead
  $details
    The details of the field in JSON. You can find more 
    info about the details from the following URL:
    https://voyager.readme.io/docs/additional-field-options
  $placeholder
    The placeholder value of the field
  $required
    Whether or not this field is required

TYPES OF FIELDS

checkbox, color, date, file, image, multiple_images,
number, password, radio_btn, rich_text_box, code_editor,
markdown_editor, select_dropdown, select_multiple, text,
text_area, timestamp, hidden, coordinates

voyager-themes's People

Contributors

akazorg avatar jeffochoa avatar marktopper avatar tnylea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voyager-themes's Issues

require.voyager-themes is invalid

When trying to install like this

php artisan hook:install voyager-themes

I get this error:

require.voyager-themes is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package 
name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-
z0-9]+)*$".

  at C:\xampp\htdocs\royal\vendor\composer\composer\src\Composer\Package\Loader\RootPackageLoader.php:147
    143▕         foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
    144▕             if (isset($config[$linkType])) {
    145▕                 foreach ($config[$linkType] as $linkName => $constraint) {
    146▕                     if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  ➜ 147▕                         throw new \RuntimeException($linkType.'.'.$err);
    148▕                     }
    149▕                 }
    150▕             }
    151▕         }

  1   C:\xampp\htdocs\royal\vendor\composer\composer\src\Composer\Factory.php:368
      Composer\Package\Loader\RootPackageLoader::load("Composer\Package\RootPackage", "C:\xampp\htdocs\royal")    

  2   C:\xampp\htdocs\royal\vendor\composer\composer\src\Composer\Factory.php:595
      Composer\Factory::createComposer(Object(Composer\IO\ConsoleIO))

Voyager Themes not work on Voyager 1.1

  • Laravel Version: 5.6.12
  • Voyager Version: 1.1.0
  • PHP Version: 7.1.14
  • Database Driver & Version: mysqlnd 5.0.12-dev - 20150407

Description:

Voyager Themes work fine on Voyager 1.0.17 but on Voyager 1.1 it NOT WORK
BECAUSE Voyager 1.1 change:
Update Configuration
The voyager.php configuration file has had a few changes. The prefix key has been removed in favor of the user.redirect key. Please note that the user.redirect key should be prefixed with a slash (/), unlike the original prefix key.

no migration

installing this hook creates the following error:

Illuminate \ Database \ QueryException (42S02)
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'velms.voyager_themes' doesn't exist (SQL: select * from `voyager_themes` where `active` = 1 limit 1)

[BUG] Route [voyager.theme.index] not defined.

Hooks Version: ^1.0
Voyager Version: 1.1.10
Laravel Version: 5.7.24
PHP Version: >=7.1.3
Description:
Themes and redirect hooks give the same error:

Route [voyager.theme.index] not defined.

Steps To Reproduce:
Try and access admin after logging in and the system gives a 500 error message.

NOTE:

Hooks Version: ^1.0
Voyager Version: 1.1
Laravel Version: 5.7.24
PHP Version: >=7.1.3

I have another project on the same local system running earlier versions of voyager and the two hook packages that work with Laravel 5.7.24.

UPDATE:

I updated the working project from Voyager 1.1 to 1.1.10 and this issue appeared.

'voyager.admin.routing' is a hard code

voyager-themes/src/VoyagerThemesServiceProvider.php at line 36:

app(Dispatcher::class)->listen('voyager.admin.routing', function ($router) {

I think 'voyager.admin.routing' is a hard code.

If I want change the prefix of voyager at routes/web.php, it do not work.
I need make a new ServiceProvider for listen.

Changing Voyager Prefix breaks admin themes path

Whenever I try to customize the voyager path prefix... say
'custom'

Route::group(['prefix' => 'custom'], function () {
    Voyager::routes();
});

Everything else works except when going to the backend theme directory.

Going to http://domain.test/custom/themes results in 404.

Any other config I need to set to fix?

No Themes Found

Wuh oh!
It doesn't look like you have any themes available in your theme folder located at C:\Users\WOK\Desktop\laravel-5.8\test\resources\views/themes

I have download the sample theme and placed it inside resources/views/theme folder and its still saying not found
i also copied it to resources folder, and views folder

but still not found

below is my config/themes.php file

return [

'themes_folder' => resource_path('views/themes'),
'publish_assets' => true

];

Undefined index

hello I am new to this, when I try to install voyager themes on console I get this error:
`ErrorException: undefined index: voyager-themes

at C: \ xampp \ htdocs \ Laravel \ codemain \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Collection.php: 1290
1286 * @mixed return
1287 * /
1288 offsetGet public function ($ key)
1289 {

1290 | returns $ this-> items [$ key];
1291}
1292
1293 / **
1294 * Set the element to a certain offset.

Exception trace:

1 Illuminate \ Foundation \ Bootstrap \ HandleExceptions :: handleError ("Undefined index: sllize-voyager-themes", "C: \ xampp \ htdocs \ Laravel \ codemain \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Collection.php ", [" voyager-themes "])
C: \ xampp \ htdocs \ Laravel \ codemain \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Collection.php: 1290

2 Illuminate \ Support \ Collection :: offsetGet ("voyager-themes")
C: \ xampp \ htdocs \ Laravel \ codemain \ vendor \ larapack \ hooks \ src \ Hooks.php: 237

Use the -v argument for more details.`

I have not found any solution, I hope you can help me, thanks

Website crash on theme options

Once I installed and enabled theme, I tried to change options but website crashes with this error:

Constant ACTIVE_THEME_FOLDER already defined (View: /var/app/current/vendor/voyager-themes/resources/views/options.blade.php

Can be fixed replacing line 58, in voyager-themes/resources/views/options.blade.php with:

<?php if (!defined("ACTIVE_THEME_FOLDER")) define("ACTIVE_THEME_FOLDER", $theme->folder); ?>

installation error crash the site

i tried to install hooks - php artisan hook:install voyager-themes , this create error on enable error=" Trying to get property of non-object" and crash the admin - snapshot: https://prnt.sc/hn35vw (edited)
also not able to uninstall this hook?

for now i have manually uninstall, and also removed base hooks json still display hooks list in browse hooks.. also cleared cache

No theme options displayed after install

Hi! could you please help me to set up this hook ?

I can't see any theme related options after install using php artisan hook:install voyager-themes

I also added the sample-theme folder to public

I also tried to run php artisan migrate but I get Nothing to migrate.

public vs resources

Why we need to save theme blade files in public folder but not in resources?

Composer Packaging name deprecated

Your composer package name voyager-themes is deprecated and should be renamed to match composers naming conventions. To accomplish this, it's enough to add your vendor name.

So changing it from: voyager-themes to devdojo/voyager-themes will fix it.
Otherwise this error will always be thrown when running any compsoer related command.

To reproduce the problem, yo need to have "voyger-themes" in your required packages inside your composer.json and then run: composer validate:

$ composer validate
Deprecation warning: require.voyager-themes is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*". Make sure you fix this as Composer 2.0 will error.
Deprecation warning: require.voyager-themes is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*". Make sure you fix this as Composer 2.0 will error.
./composer.json is valid, but with a few warnings
See https://getcomposer.org/doc/04-schema.md for details on the schema

Error report for version 0.8

That is my first time of installing voyager-thems.
I found some errors.

I use maria DB latest version.
The index of folder varchar 255 is too long.
so I chang the code of vendor/voyager-themes/src/VoyagerThemesServiceProvider.php at line 179

$table->string('folder', 191)->unique();

Then, it create the tables. well.

But


/var/www/webapp/vendor/voyager-themes/src/VoyagerThemesServiceProvider.php at line 154
   
$middleware_folder = $themes_folder . '/' . $theme->folder . '/middleware';

takes an error:

"Trying to get property of non-object"

so, I add that

if (empty($theme)) { 
  return;
}

under line 153.

Undefined property $id when access themes option

I got this error when access to themes option:
Undefined property: stdClass::$id (View: /home/vagrant/code/test/vendor/tcg/voyager/resources/views/formfields/image.blade.php)

After 1 hour deep dive into Voyager Admin source
I found the problem is Voyager Admin updated file image.blade.php at line 5, they want get $dataTypeContent->id
But helpers.php missing it at line 17 $dataTypeContent = (object)[$key => $content];.

I tried change it to $dataTypeContent = (object)["id" => 0, $key => $content]; and it worked.

I don't know how to fix it, I just report issue and hope you guys fix it as correct way. Thanks!

Simple Voyager Themes Instructions

Hi
I am using Voyager 1.1 & Laravel 5.6.12 but no luck to adding the theme with instructions here :(
I don't have any error and even I don't see the the menu/option in the admin area after following the instructions here to set it up!
If its not support Laravel 5.6, can you please explain for Laravel 5.5 simple step by step how to ?

Best Regards!

Multiple themes doesn't work

hey..i waste to much time to import your package in mine...so many errors and you don't have full documentation for everything to set up it correctly.. nevermind it run ok now but i don't know if support multiple themes..think that each theme is each front end page...when i activate second theme its not working..it is possible to fix that? or missing something and don't run perfectly that why i have that problem?

Error on artisan config:cache

On run php artisan config:cache

Configuration cache cleared!

In Theme.php line 16:

Cannot declare class VoyagerThemes\Models\Theme, because the name is already in use

require.voyager-themes is invalid

php artisan hook:install voyager-themes

require.voyager-themes is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".

  at vendor/composer/composer/src/Composer/Package/Loader/RootPackageLoader.php:149
    145▕         foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
    146▕             if (isset($config[$linkType])) {
    147▕                 foreach ($config[$linkType] as $linkName => $constraint) {
    148▕                     if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  ➜ 149▕                         throw new \RuntimeException($linkType.'.'.$err);
    150▕                     }
    151▕                 }
    152▕             }
    153▕         }

      +29 vendor frames
  30  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

What do you think could be the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.