GithubHelp home page GithubHelp logo

typerocket / core Goto Github PK

View Code? Open in Web Editor NEW
36.0 36.0 21.0 2.38 MB

TypeRocket core source files where all the magic lives.

Home Page: https://typerocket.com

PHP 88.30% Shell 0.07% JavaScript 5.64% SCSS 5.99% Hack 0.01%

core's Introduction

Total Downloads Latest Stable Version License

About TypeRocket

TypeRocket is a WordPress framework that beautifully joins refined UI elements and modern programming architecture together, creating a cohesive developer experience. By bringing TypeRocket into your workflow you can save countless hours of development and painlessly craft WordPress applications with:

  • View and logic separation in your theme templates.
  • Beautiful form UI creation with 29+ custom field types and flexible data binding.
  • Fluent post type, meta box, taxonomy and admin page registration.
  • Powerful ORM with eager loading and deep WordPress integration.
  • Component based page builder that you control.
  • Policy, capability, and role management.
  • WP Cron powered jobs and queue system.
  • Laravel inspired routing and controllers.
  • Modern dependency injection container.
  • Symfony based CLI called Galaxy.

TypeRocket is a sleek, powerful, and modernizes WordPress.

Getting Started

TypeRocket v6 Antennae is well documented, and we have many video tutorials and written articles to help you get started. TypeRocket is easy to install via composer project or as a WordPress plugin.

Pro Version

TypeRocket Pro is a paid upgrade to TypeRocket v6 Antennae. To learn more about TypeRocket Pro see our comparison chart.

License

TypeRocket is open-sourced software licenced under the GNU General Public License 3.0.

core's People

Contributors

eric-michel avatar fuelingtheweb avatar hex0id avatar jhlindgren avatar kevindees avatar marbetschar avatar mohamed-abdul-fattah avatar nullvariable avatar rbmayer avatar robojuicedev avatar szepeviktor avatar totya24 avatar zackphilipps 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

core's Issues

Raw sql for order by (model query)

Regards,
I have a model where I need to pull 15 random rows,
but this didn't work:
->orderBy(NULL, 'RAND()') // params are only $column and $direction
But I found the solution/hack with this:
->appendRawWhere(null, 'ORDER BY RAND()')
Is there some other way to add custom sql?

Add filter when casting properties in model

In the base model, the provisionFields method has a filter at the end:

 return apply_filters( 'tr_model_provision_fields', $fields, $this );

It would useful to have the same kind of filter in the castProperties method.

How to delete /wordpress from URL using with the .htaccess file?

Hi,

Here is my .htaccess file how it looks like.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projects/sitename/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projects/sitename/wordpress/index.php [L]
</IfModule>
# END WordPress

I want to use my URL like this: https://mydomain/projects/sitename/

I need to learn the settings of the .htaccess file because I will use to my client projects after this.

Waiting for a solution, thank you in advance and best regards!

Reference component data from within another component

I am fairly new to TypeRocket, so please bear with me.
I've created a simple component much like the Content Component that comes bundled for the Page Builder. Now I have another component with a search field, where one can add pages in the component. And I would like to get the $data['content'] from that other component and pull it's value into this one. The only way I could manage to do it was to create a query that queries the post_meta table for the page_id and 'builder' meta_key.
Isn't there supposed to be a more elegant way to do this?

Database fields in camelCase not supported inside tr_form

Regards,
I am using custom resources ie custom tables,
and in my edit.php form I have camelCase field like this:
echo $form->text('myField')
but it looks like this field's value is not populated (in form).
In my add.php form, I found that the field are converted
to lowercase and knowing that I just fetch myfield and this works.
Update: I found temporary solution, where I need to manually convert those fields, but this is not very practical:

        $model = (new Entity)->findOrDie($id);
        $model->myfield = $model->myField;
        $form = tr_form($this->modelSlug, 'update', null, $model);

Can you implement camelCase support here?
Also, can I suggest that you improve the docs with tr_form's 4th argument? Because this doesn't work:
$form = tr_form($this->modelSlug, 'update', $id);
but this does:
$form = tr_form($this->modelSlug, 'update', null, $model);
and this also doesn't work:
$form = tr_form($this->modelSlug, 'update', $id, $model);

WPUser class throws a notice when user is not found

Not sure what the expected behavior would be, but if I use a user id that does not exist, I get a notice:

Notice: Trying to get property 'data' of non-object in ..../typerocket/vendor/typerocket/core/src/Models/WPUser.php on line 64
--
  |  
  | Call Stack:
  | 0.0001     428752   1. {main}() /app/index.php:0
  | 0.0001     429040   2. require('/app/wp-blog-header.php') /app/index.php:17
  | 0.2115   14645880   3. wp() /app/wp-blog-header.php:16
  | 0.2115   14645904   4. WP->main() /app/wp-includes/functions.php:964
  | 0.2148   14737696   5. WP->query_posts() /app/wp-includes/class-wp.php:717
  | 0.2148   14737856   6. WP_Query->query() /app/wp-includes/class-wp.php:601
  | 0.2148   14737856   7. WP_Query->get_posts() /app/wp-includes/class-wp-query.php:3230
  | 0.2155   14757696   8. apply_filters_ref_array() /app/wp-includes/class-wp-query.php:2706
  | 0.2155   14757696   9. WP_Hook->apply_filters() /app/wp-includes/plugin.php:244
  | 0.2155   14759200  10. ....\Core->posts_clauses_request() /app/wp-includes/class-wp-hook.php:286
  | 0.2156   14763264  11. App\Models\User->findById() /app/wp-content/mu-plugins/..../includes/core.php:169

I can check the user object for an ID at that point, and it will return a null value.

Essentially the $user->data property returned by the get_user_by function is null when the user doesn't exist, so trying to set the result using that property fails. For my use case, I need the user object, even if the user doesn't exist ( or is logged out ).

It's easy for me to check for logged out user ids since that will always be 0, but if for some reason there was a case where a user id that wasn't zero didn't exist, I feel like the WPUser object should be more informative. @kevindees Thoughts?

I would like to make bundles using TypeRocket

I'm venturing into making a standalone plugin of TypeRocket and creating bundle plugins of specific functionalities to enable better code reuse.

The biggest problem I'm seeing at first look is the reliance on TR_APP_NAMESPACE to instantiate classes. This prevents the use of different namespaces in bundles and create possible name collisions.

I see that it is still the case in version 4.0.0.

Would it be possible to move class name generation to somewhere that would be less hardcoded?

Would bundling be a desirable feature in the core? I could work on it.

TypeRocket + Trellis/Bedrock/Sage?

Duplicate of my post over at the Roots forum. https://discourse.roots.io/t/best-way-to-integrate-the-typerocket-framework/16159

I saw the option in TypeRocket/typerocket#175 about using rooted TypeRocket but since I'm using Trellis/Bedrock I don't believe that is a viable solution.


Been beating my head against this for several days so I'm asking for help.

I'm trying to use the TypeRocket framework within a Trellis/Bedrock/Sage environment. I believe that it will be a more simplified solution than CPTUI+ACF or some other combination.


According to the install directions, the best way is to include it as an mu-plugin so that it's not theme dependent and is available anywhere within the WP environment. Unfortunately the documentation expects that to be a manual install instead of as a dependency. (https://typerocket.com/docs/v4/installation/#section-mu-plugin)

  • I do want it as an mu-plugin
  • I do want to be able to leverage its functionality from within Sage templates

  • I don't want to include it in the theme since I may want to leverage it on API pages.
  • I don't want to manually force it in as an mu-plugin and include it in source control because that is not my code.

My first issue was that it's not available through wpackagist and therefore wasn't controllable via the normal composer installers and the Bedrock mu autoloader. I ended up at this Stackoverflow answer and used the oomphinc/composer-installers-extender package so that I could follow past threads advice and get it into the mu-plugins folder with:

"extra": {
  "installer-types": ["library"],
  "installer-paths": {
    "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin", "typerocket/typerocket"],

This gets it into the web/app/mu-plugins folder but doesn't actually load it since it also needs an additional file to actually include the init file. require_once('typerocket/init.php');

Adding that file to mu-plugins doesn't work because TypeRocket is expecting to have been installed as a standalone composer package via composer create-project --prefer-dist typerocket/typerocket. It then checks for its own vendor directory or alternatively looks you to pass in a custom function via TR_AUTO_LOADER. (source code)

I'm digging into the Composer/PSR-0/PSR-4 stuff but don't feel like I'm going to know the answer when I see it.


The second potential solution is loading it as a normal vendor package but requiring it from within the mu-plugins folder.

The issues with this appear to be several:

  • I still have to manually init it from mu-plugins
  • Some of the assets from the frameworks folders are meant to be publicly accessible via the WPMU_PLUGIN_URL path which can't be done from the top-level vendor folder without some symlink magic.

So, what's the best way to accomplish what I'm going for?

  • Suck it up and just include it as a theme dependency?
  • Force-add it as a manual mu-plugin that's committed with my code?
  • Muck up some kind of Composer script to hook the pre-package-install event and redirect the paths to where it expects to be?
  • Turn it into an Ansible dependency and take Composer out of the equation?
  • Open an issue and wait for the framework to get updated?
  • Give up coding because my conceptions of 'the right way to do things' are all wrong and go live on a commune some where?

Thank you for any help or direction you can provide.

Search field: Trigger change event on hidden field after setting ID

I'd love to link the search field to another field, where the value should be set dynamically depending on whatever is selected in the search field.

For this, I'd love to bind the on change event of the hidden input field which receives the ID of the selected post type. But unfortunately this event is never fired.

According to this thread on StackOverflow the on change event of an input field must be triggered manually.

Any chance you can add this triggering in your code for selecting and removing a post type?

if( !keying || enterKey) {
var id, title;
id = $(this).data('id');
title = $(this).text();
$(this).parent().prev().html('Selection: <b>' + title + '</b> <a class="tr-link-search-remove-selection" href="#remove-selection">remove</a>');
that.next().val(id);

Image and file option in Redactor are not available

Hey Kevin,

i set the button array for Redactor like in the Documentation, but image and file options are not available, everything else i can enable and disable.
Is there another point, where i have to enable this features or is it not implemented?

Greetings,

Lucas

Child Themes

I've built a theme that uses TypeRocket, but is it possible to have a child theme that also uses the TypeRocket functionality?

Regards
Gary

Adding Repeater fields the other Way?

Hi @kevindees

First off all. I really felt in Love with TypeRocket. Even that i'm totally new to WordPress Developing (i developed more than 10 Year with ColdFusion). I was able to get into it extremly fast, mostly because of TypeRocket - so thanx a lot for this cool Magic!

I still got some Issue with changeing from /mu-plugin install to build-it, so i can public my new Plugin in WordPress Library as well. But i'll RTFM first again and hope i'll get it.

My Problem/Question is about the Repeater Fields.

How can i change the Usability so my Customers love to use it as well.
Now it is: That the "Add New" Button is on Top and the new Fields are dropping underneath.
What i love to do is, that the "Add new" Button is/stay at the Buttom and the new fields are inserted every time on top (over the "Add new" Button.

Because my Users are use to "add" things like this. And when they are adding nuew Invoice Positions, they have to rearange those (each) positiones every time.

Do you know what i mean?

HowItIs

HowItShouldBe

Sortable columns not working + fix

Hi,

Using TypeRocket right now for a project because I kind of like both WordPress and Laravel.

Came across an issue regarding custom sorting of columns in admin.

In core/src/Register/Registry.php line 306 it says:
add_filter( "manage_edit-{$pt}_sortable_columns", function() use ($new_column) {
This should be:
add_filter( "manage_edit-{$pt}_sortable_columns", function($columns) use ($new_column) {

Otherwise only one the last of the new defined sortable columns will be sortable.

Kind regards
Wesley / Synio

ajax error

Out of nowhere I got this problem with a part of my script that has been working fine for weeks.
An ajax error is occurring: "Your request had an error. 404 - Not Found" and I have no idea how this can happen or what is causing this.

It happen in an admin form that submits some value's to the options table. This was tested and has been working fine, but today I installed a new environment (vagrant) and cloned the lastest TypeRocket (as MU-plugin). I put my own scripts in and tried to use the form to setup some variables in the options table. But I got this error as mentioned and the inspecting the browser I find that this is caused bu URL: https://one.wordpress.test/tr_json_api/v1/option/

I made sure that all the files involved are in the right place and have no errors. I hHave no clue what is happening, so hopefully you could give me some pointers how to approach this problem.

Thanks in advance.

Upgrade from v3

Hi

In order to upgrade from V3 to ProV1, is it easier to do :

V3 --upgrade to--> V4 --upgrade to--> ProV1

or

V3 --upgrade to--> ProV1

Thx

Best way to set a repeater field required

Hey,

first of all i want to say, that i really like TypeRocket! It gives me the possibility to extend post types, which comes from another plugin in a simple way. Great :)

I have just a little question. What is the best way to set a textfield required, which is defined in a repeater?
I think about to use the raw render setting and use html required attribute, but maybe there is better way to that.

Greetings from germany,

Lucas

Redirect->toUrl improperly convert & to html entity

The use of esc_url in the toUrl method of the Redirect class breaks redirects with query strings by converting & to #038;:

public function toUrl( $url ) {
        $this->url = esc_url($url);
        return $this;
}

esc_url shouldn't be used here since it is meant to be used for outputting URLs in the DOM. esc_url_raw would be a better fit.

Typerocket endpoints with a non-https home url break when accessed from https

?><script>window.trHelpers = {site_uri: "<?php echo esc_url(home_url());?>"}</script><?php

If your home url is http, but you're accessing the site from the https version, queries to the TypeRocket endpoints using the trHelpers.site_uri will fail with a mixed content error.

The solution for this is to use the $scheme parameter of home_url to use https if a page is loaded with https.

Validator - rules pass if variable not present in request

I've had a weird problem with bots - a contact form sending empty emails. I've set some fields as "required", but if I posted the form without the $_POST[tr] array entirely (only _tr_nonce_form present), the validator passes - in these cases $this->request->getFields() returns an empty array.

What I did is checking manually eg. isset($_POST['tr']['email']) before the TypeRocket validator, but I suspect this shouldn't work like this.

WhereMeta behaves incorrectly when meta value doesn't exist

The docs demonstrate the ability to check if a meta value equal to null. However, this only works if the meta_key exists in the table (was set earlier and then emptied). Therefore, there's no way to use whereMeta to check for the existence of a meta key and then check if it's blank.

From the docs:
(new Post) ->whereMeta([ [ 'column' => 'feature', 'operator' => '!=', 'value' => null ],...

Date field type format

Date type custom fields (eg. $form->date('event_date')) are formatted dd/mm/yyyy - input fields have their values in this format, and are also saved in the database like this. The default format for <input type="date"> should be yyyy-mm-dd. I'm aware that these are not type="date" fields, but still should be formatted like so.
When parsing these dates from the database, php mixes up months with days. (eg. if you do something like new DateTime($post->event_date), it returns a DateTime object with the month and day mixed up).

Edit: As a workaround, I could use $form->text('event_date')->setAttribute('type', 'date'), which works as it should, so not a big deal, but the feature should still work correctly once it's implemented.

Usage in public plugins

Hi there,

Apologies if this isn't the right place to get in touch about this. I couldn't find a contact page on the TypeRocket website.

I've read this page https://typerocket.com/how-to-use-and-install-typerocket/ and I understand you guys discourage usage of the framework if I don't have control of the website due to potential collisions.

Would it be possible to use typerocket is a public plugin that would be distributed through WordPress.org but only after using this https://github.com/humbug/php-scoper ?

I'm developing a very complex plugin and I believe your framework is the only way to make the development experience wonderful.

Please let me know.

Regards.

Galaxy CLI make:migration issue

Hello,
When im trying to create new migration with galaxy cli as it is described in documentation i get these errors:

C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket>php galaxy make:migration add_lesson_sources_table
PHP Warning:  file_exists() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket\vendor\typerocket\core\src\Console\Commands\MakeMigration.php on line 36

Warning: file_exists() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket\vendor\typerocket\core\src\Console\Commands\MakeMigration.php on line 36
TypeRocket trying to locate Array for migrations.
PHP Warning:  mkdir() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket\vendor\typerocket\core\src\Console\Commands\MakeMigration.php on line 38

Warning: mkdir() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket\vendor\typerocket\core\src\Console\Commands\MakeMigration.php on line 38
Location created...
PHP Warning:  fopen(Array/1569782985.add_lesson_sources_table.sql): failed to open stream: No such file or directory in C:\xampp\htdocs\poligon2\wp-content\mu-plugins\typerocket\vendor\typerocket\core\src\Utility\File.php on line 84

I have enabled wp commands, this is MU plugin installation.
It is php 7.3.5 with all required extensions and fresh wordpress 5.2.3 instalation.
Tell me if you need any other information.

typerocket theme dependence

Hello, I am impressed by the typerocket framework and want to use it embedded in my plugin but I am concerned that it is dependent on the installed theme. I would like my plugin to operate regardless of theme being deleted/changed.

Looking at the config, it appears the use of the theme directory is hardcoded for important TR directories like 'resources'. Is this correct or am I missing something?

I saw in Issue #21 discussing namespace which was another concern given one of my plugin users has typerocket already installed. What is the best practice for handling compatibility if I wanted to accomplish a standalone theme-independent plugin powered by TypeRocket?

thank you

Can't modify request fields in view, WPPostController::create() fails silently if there's no post_title

Hi,

I'd like to set post_title on the fly in my view, like so:

    public function create()
    {
	‌‌$this->request->fields['post_title'] = $this->fields['first_name'] .' '. $this->fields['last_name'];
	parent::create();
    }

But request->fields is protected, so that won't work. What's the best way to do it?

In Laravel you can do something like:

  $request->request->add(['new_field' => 'yup']);
  User::create($request->all());

Also, if I simply don't set post_title (nor any other $builtin field), WPPost::create() fails without throwing any error, because of all the checks being inside if ( ! empty( $builtin )). The same would happen for update(), if I tried very hard. :)

Pro version

Hello
I heard there is a Pro version in the making.
Is there a release date already ?
Thx

Form fields - hide bug icon

Regards,
how to hide bug icon (div with css class 'dev') on all typerocket form fields?
I need to hide it for certain wordpress user roles.
I could do it with jQuery, but is there some typerocket option to do just that?

WordPress salts failed

Hello, whenever I install typerocket from composer and type the use:root command, I get this error:
"WordPress salts failed".

I think the regex used in this file is the culprit:

$regex = "/define(.*)here\\'\\)\\;/m";

Should be this I guess (removed unnecessary backslashes):

$regex = "/define(.*)here'\);/m";

Polylang issue

Hello
When adding translate to existing post with Polylang, it gives error:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function TypeRocket\Http\Responders\Hook::taxonomies(), 1 passed in C:\xampp\htdocs\epos-guest\wp-includes\class-wp-hook.php on line 288 and exactly 3 expected in C:\xampp\htdocs\epos-guest\wp-content\themes\epos-guest-cms\typerocket\vendor\typerocket\core\src\Http\Responders\Hook.php:55 Stack trace: #0 C:\xampp\htdocs\epos-guest\wp-includes\class-wp-hook.php(288): TypeRocket\Http\Responders\Hook::taxonomies(2315) #1 C:\xampp\htdocs\epos-guest\wp-includes\class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 C:\xampp\htdocs\epos-guest\wp-includes\plugin.php(465): WP_Hook->do_action(Array) #3 C:\xampp\htdocs\epos-guest\wp-includes\taxonomy.php(2987): do_action('edit_term', 2315, 2315, 'post_translatio...') #4 C:\xampp\htdocs\epos-guest\wp-content\plugins\polylang-pro\modules\sync\sync-post.php(313): wp_update_term(2315, 'post_translatio...', Array) #5 C:\xampp\htdocs\epos-guest\wp-content\plugins\polylang-pro\modules\sync\sync-post.php(260): PLL_Sync_Pos in C:\xampp\htdocs\epos-guest\wp-content\themes\epos-guest-cms\typerocket\vendor\typerocket\core\src\Http\Responders\Hook.php on line 55

Example frontend app?

Hi,

this project looks great. I can't imagine why it hasn't gonne viral yet. Except, perhaps, because of the learning curve. The docs could be improved (at least for those of us not familiar with Laravel), and specially, because I can't find any example frontend app to play with. I'm trying to create a "Book" example picking up the tidbits from the docs, but I keep hitting wall after wall. Might I suggest you publish one to make for a smoother TypeRocket launch?

Something like http://todomvc.com/ would be great (and good publicity too ;)

Invalid CSRF Token on post() route

Regards,
I am using wordpress 5.3 and PHP 7.2. with typerocket as a plugin, to create some frontend routes. GET requests are working, but POST routes do not. Example: tr_route()->post()->match('data/post')->do('test@Data') return this error: "Invalid CSRF Token". So I investigated typerocket core a little and
found that TR needs some special POST field named like this:
$token = check_ajax_referer( 'form_' . Config::locate('app.seed'), '_tr_nonce_form', false );
And I tried to create nonce with:
wp_create_nonce('form_<APP_SEED>_tr_nonce_form');
and put it's response into next post request like this
_ajax_nonce=c87565cbaf
but this also returns the same error.
Also, when I comment out middleware file "BaseVerify.php" lines 26-31 then
the post requests begin to work, but this is only temporary solution.
Can you help, or point to some relevant docs,

Thanks

Primary key name issue

Hi guys,

I think I found a bug related to the custom resource's primary key name. By default this column is named "id" and if you follow this convention everything works as expected. On the other hand if you try something more exotic ex. (exotic_id), the code will not work.

How to replicate this bug?
Create "base" Controller/Model with galaxy command line tool. Set idColumn property in your Model to "exotic_id". Create a table with primary key named "exotic_id". Create add and edit views.

Make an entry to the database. Try to edit. (SQL Error - Column id does not exist!).

core/src/Models/Model.php:53

$this->query->table($table);       

// Should be:

$this->query->table($table);
$this->query->setIdColumn($this->idColumn);

core/src/Elements/Tables.php:333-343 should be replaced with:

if ($page->action == 'edit') {
       $edit_url = $page->getUrl(['route_id' => (int)$result->$columnId]);
}

if ($page->action == 'show') {
    $show_url = $page->getUrl(['route_id' => (int)$result->$columnId]);
}

if ($page->action == 'delete') {
    $delete_url = $page->getUrl(['route_id' => (int)$result->$columnId]);
}

Cheers,
M.

Unable to save data for custom posttype to custom table

Hey,

I don't know if it's my issue, but I can't save custom post type data into a custom table like in your tutorial on youtube, where the way is explained very good :)

It seems to be, there is a problem with the id-column, because columns will be created, with the correct data, but with NULL id.

What do I have to change to deal with post_id column correctly on the custom table?

That's my code:

<?php
namespace App\Models;

use \TypeRocket\Models\WPPost;

class Fach extends WPPost
{
    protected $postType = 'fach';

    protected $metaless = [
    	'details',
    ];

    public function details(){
       return $this->hasOne(FachDetails::class, 'post_id');
    }
}
<?php
namespace App\Controllers;

use \App\Models\Fach;
use \App\Models\FachDetails;
use \TypeRocket\Controllers\WPPostController;

class FachController extends WPPostController
{
    protected $modelClass = Fach::class;

    public function update($id = null){

    	$fields = $this->request->getFields('details');

    	console_log($id);

    	(new FachDetails())->findOrNew($id)->save($fields);

    	parent::update($id);

    }
}
<?php
namespace App\Models;

use \TypeRocket\Models\Model;

class FachDetails extends Model
{

    protected $resource = 'fach_details';
    
    protected $fillable = [
        'methodik_db_id',
        'hochschultyp',
    	'untertitel'
    ];

    public function fach(){
       return $this->belongsTo(Fach::class, 'post_id');
    }
}
<?php
namespace App\Models;

$fach = tr_post_type('Fach', 'Fächer');
$fach->setTitlePlaceholder( 'Fachname hier eingeben' );
$fach->setIcon('graduation');
$fach->setArgument('supports', ['title'] );
$fach->setSlug('faecher');
$fach->setEditorForm(function() {
    $form = tr_form()->setGroup('details');
    echo $form->text('Methodik-DB-ID')->setType('number');
    $options = [
        'Universitäten' => '1',
        'Fachhochschulen / HAW' => '2',
        'Berufsakademien' => '3',
    ];
    echo $form->select('Hochschultyp')->setOptions($options);
    echo $form->text('Untertitel');
});

Ability to format search results

It would be awesome to be able to customize the way search results are displayed. Right now it seems the JavaScript implementation is rather static and does not allow for customizations:

if (item.post_title) {
if (item.post_status === 'draft') {
post_status = 'draft ';
} else {
post_status = '';
}
title = item.post_title + ' (' + post_status + item.post_type + ')';
id = item.ID;
} else if(item.term_id) {
title = item.name;
id = item.term_id;
} else {
title = item.title;
id = item.id;
}

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.