[TaylorJ] Blogs

[TaylorJ] Blogs 1.3.0

No permission to download
Every time you post an upgrade, some people receive an email. If you do this three times a day, I get an email from you three times a day. I don't want that, and I would have to remove myself from the mailing list, which means I won't get any information from you at all.

Do you think you could work in larger steps and not post an update for every single function?

Just imagine if everyone did this. Our inboxes would overflow, and the Xenforo servers would crash.

If small improvements have a big impact on active add-on users, I think it's okay. For example, I have all my notifications turned on and I follow the current development. I want to see these developments. I think there's no problem with that. I think reacting blogs is a good enough reason to update. The rest are bug fixes.
 
Hey Taylor, On trying to update I am getting:

View attachment 308238View attachment 308239
And this is what happens when I don't pay attention to the differences between altering and creating tables in the setup file

I'll have this fixed later today on an updated beta 4 version (won't create a new beta just for this), until then though in the src/addons/TaylorJ/Blogs/Setup.php file you can change line to the below
PHP:
$this->alterTable('xf_taylorj_blogs_blog_post', function (\XF\Db\Schema\Alter $table)
Just changing \XF\Db\Schema\Create to \XF\Db\Schema\Alter
 
Every time you post an upgrade, some people receive an email. If you do this three times a day, I get an email from you three times a day. I don't want that, and I would have to remove myself from the mailing list, which means I won't get any information from you at all.

Do you think you could work in larger steps and not post an update for every single function?

Just imagine if everyone did this. Our inboxes would overflow, and the Xenforo servers would crash.
Yesterday was a one off when it came to updates per day, sorry for the excess alerts/emails. I decided to go ahead and release a version with reactions since I had scuffed up the earlier release by including some of its logic when it didn't need to be there and decided just not to wait.

There will be an update today to address the setup.php error but that will be about it and other releases will wait until a big feature has been completed or multiple smaller ones. Haven't fully fleshed out my release schedule/cycle as of yet.
 
What excellent responses from all of you! Great job. I like it. There’s a real buzz here, things are really happening. So keep it up! And I'll turn off the notification sound for incoming emails, so it won't bother me anymore. :)
 
Just for info, when trying to install the add-on on a XF2.3 instance:

1723144425933.webp

Code:
InvalidArgumentException: Batch install error: xf_taylorj_blogs_blog_post: Column type 'VARCHAR' for column 'blog_post_state' must include a length. src\XF\Db\Schema\Column.php:466

#0 src\XF\Db\Schema\Column.php(443): XF\Db\Schema\Column->getColumnDefinitionSql()
#1 src\XF\Db\Schema\Create.php(86): XF\Db\Schema\Column->getDefinition()
#2 src\XF\Db\Schema\AbstractDdl.php(154): XF\Db\Schema\Create->getQueries()
#3 src\XF\Db\SchemaManager.php(194): XF\Db\Schema\AbstractDdl->apply()
#4 src\XF\Install\InstallHelperTrait.php(907): XF\Db\SchemaManager->createTable('xf_taylorj_blog...', Object(Closure))
#5 src\addons\TaylorJ\Blogs\Setup.php(52): XF\AddOn\AbstractSetup->createTable('xf_taylorj_blog...', Object(Closure))
#6 src\XF\AddOn\StepRunnerInstallTrait.php(62): TaylorJ\Blogs\Setup->installStep2(Array)
#7 src\XF\AddOn\StepRunnerInstallTrait.php(29): TaylorJ\Blogs\Setup->installStepRunner(2, Array)
#8 src\XF\Job\AddOnInstallBatch.php(299): TaylorJ\Blogs\Setup->install(Array)
#9 src\XF\Job\AddOnInstallBatch.php(95): XF\Job\AddOnInstallBatch->stepAction(Object(XF\Timer))
#10 src\XF\Job\Manager.php(275): XF\Job\AddOnInstallBatch->run(8)
#11 src\XF\Job\Manager.php(205): XF\Job\Manager->runJobInternal(Array, 8)
#12 src\XF\Job\Manager.php(121): XF\Job\Manager->runJobEntry(Array, 8)
#13 src\XF\Admin\Controller\ToolsController.php(146): XF\Job\Manager->runByIds(Array, 8)
#14 src\XF\Mvc\Dispatcher.php(362): XF\Admin\Controller\ToolsController->actionRunJob(Object(XF\Mvc\ParameterBag))
#15 src\XF\Mvc\Dispatcher.php(265): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#16 src\XF\Mvc\Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#17 src\XF\Mvc\Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#18 src\XF\App.php(2813): XF\Mvc\Dispatcher->run()
#19 src\XF.php(802): XF\App->run()
#20 admin.php(15): XF::runApp('XF\\Admin\\App')
#21 {main}

array(4) {
  ["url"] => string(34) "/xenforo23/admin.php?tools/run-job"
  ["referrer"] => string(50) "http://localhost/xenforo23/admin.php?tools/run-job"
  ["_GET"] => array(1) {
    ["tools/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(86) "http://localhost/xenforo23/admin.php?add-ons/install-from-archive-complete&batch_id=22"
    ["_xfToken"] => string(8) "********"
    ["only_ids"] => string(3) "758"
  }
}
 
Last edited by a moderator:
Just for info, when trying to install the add-on on a XF2.3 instance:

View attachment 308307

Code:
InvalidArgumentException: Batch install error: xf_taylorj_blogs_blog_post: Column type 'VARCHAR' for column 'blog_post_state' must include a length. src\XF\Db\Schema\Column.php:466

#0 src\XF\Db\Schema\Column.php(443): XF\Db\Schema\Column->getColumnDefinitionSql()
#1 src\XF\Db\Schema\Create.php(86): XF\Db\Schema\Column->getDefinition()
#2 src\XF\Db\Schema\AbstractDdl.php(154): XF\Db\Schema\Create->getQueries()
#3 src\XF\Db\SchemaManager.php(194): XF\Db\Schema\AbstractDdl->apply()
#4 src\XF\Install\InstallHelperTrait.php(907): XF\Db\SchemaManager->createTable('xf_taylorj_blog...', Object(Closure))
#5 src\addons\TaylorJ\Blogs\Setup.php(52): XF\AddOn\AbstractSetup->createTable('xf_taylorj_blog...', Object(Closure))
#6 src\XF\AddOn\StepRunnerInstallTrait.php(62): TaylorJ\Blogs\Setup->installStep2(Array)
#7 src\XF\AddOn\StepRunnerInstallTrait.php(29): TaylorJ\Blogs\Setup->installStepRunner(2, Array)
#8 src\XF\Job\AddOnInstallBatch.php(299): TaylorJ\Blogs\Setup->install(Array)
#9 src\XF\Job\AddOnInstallBatch.php(95): XF\Job\AddOnInstallBatch->stepAction(Object(XF\Timer))
#10 src\XF\Job\Manager.php(275): XF\Job\AddOnInstallBatch->run(8)
#11 src\XF\Job\Manager.php(205): XF\Job\Manager->runJobInternal(Array, 8)
#12 src\XF\Job\Manager.php(121): XF\Job\Manager->runJobEntry(Array, 8)
#13 src\XF\Admin\Controller\ToolsController.php(146): XF\Job\Manager->runByIds(Array, 8)
#14 src\XF\Mvc\Dispatcher.php(362): XF\Admin\Controller\ToolsController->actionRunJob(Object(XF\Mvc\ParameterBag))
#15 src\XF\Mvc\Dispatcher.php(265): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#16 src\XF\Mvc\Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\ToolsController), NULL)
#17 src\XF\Mvc\Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#18 src\XF\App.php(2813): XF\Mvc\Dispatcher->run()
#19 src\XF.php(802): XF\App->run()
#20 admin.php(15): XF::runApp('XF\\Admin\\App')
#21 {main}

array(4) {
  ["url"] => string(34) "/xenforo23/admin.php?tools/run-job"
  ["referrer"] => string(50) "http://localhost/xenforo23/admin.php?tools/run-job"
  ["_GET"] => array(1) {
    ["tools/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(86) "http://localhost/xenforo23/admin.php?add-ons/install-from-archive-complete&batch_id=22"
    ["_xfToken"] => string(8) "********"
    ["only_ids"] => string(3) "758"
  }
}
Thank you for this!
 
@Taylor J

InvalidArgumentException: xf_taylorj_blogs_blog_post: Column type 'VARCHAR' for column 'blog_post_state' must include a length. in src/XF/Db/Schema/Column.php at line 466
  1. XF\Db\Schema\Column->getColumnDefinitionSql() in src/XF/Db/Schema/Column.php at line 443
  2. XF\Db\Schema\Column->getDefinition() in src/XF/Db/Schema/Create.php at line 86
  3. XF\Db\Schema\Create->getQueries() in src/XF/Db/Schema/AbstractDdl.php at line 154
  4. XF\Db\Schema\AbstractDdl->apply() in src/XF/Db/SchemaManager.php at line 194
  5. XF\Db\SchemaManager->createTable() in src/XF/Install/InstallHelperTrait.php at line 907
  6. XF\AddOn\AbstractSetup->createTable() in src/addons/TaylorJ/Blogs/Setup.php at line 36
  7. TaylorJ\Blogs\Setup->installStep2() in src/XF/AddOn/StepRunnerInstallTrait.php at line 62
  8. TaylorJ\Blogs\Setup->installStepRunner() in src/XF/AddOn/StepRunnerInstallTrait.php at line 29
  9. TaylorJ\Blogs\Setup->install() in src/XF/Admin/Controller/AddOnController.php at line 435
  10. XF\Admin\Controller\AddOnController->actionInstall() in src/XF/Mvc/Dispatcher.php at line 362
  11. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264
  12. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2777
  15. XF\App->run() in src/XF.php at line 798
  16. XF::runApp() in admin.php at line 15
 
Also @Old Nick / and anyone else that wants the hot fix for this

In src/addons/TaylorJ/Blogs/Setup.php replace both lines 48 and 72 with the below
PHP:
$table->addColumn('blog_post_state', 'enum')->values(['visible','schdeduled'])->setDefault('visible')

This will be included on the next beta but I've had more difficulty getting alerts to send out to everyone that's watched a blog than I expected.
 
Works fine now... if you add a ; at the end of the line code you provided ;)

Phrase:
1723188413676.webp

A little thing: in general and by convention the permissions of third-party add-ons appear at the end of the list on the permissions page, there they appear at the top of the list.
 
Last edited by a moderator:
XF2.3

Header image is distorted

Capture d'écran 2024-08-09 073254.webp


Style variation is not applied here

Capture d'écran 2024-08-09 073315.webp

And it would also be more conventional if the answer values of Created by (Author maybe?), Created on (Creation date maybe?) and Total posts were displayed aligned to the right, like resource infos. (It's a very small detail but the titles mentioned above should be dimmed in color).

Capture d'écran 2024-08-09 073650.webp

Perhaps you should also use a name specific to blogs for the "Posts", in general we speak of "Blog entry" or perhaps even "Blog article", it would be less confusing with the "Posts" which correspond more to thread replies. This is manageable by everyone with the phrases but I specify it for all purposes.
 
Last edited by a moderator:
XF 2.3

Trying to create a blog entry:

1723189618662.webp


Code:
XF\Db\Exception: MySQL statement prepare error [1054]: Unknown column 'view_count' in 'field list' src\XF\Db\AbstractStatement.php:230

Stack trace
INSERT  INTO `xf_taylorj_blogs_blog_post` (`blog_post_title`, `blog_id`, `blog_post_content`, `blog_post_last_edit_date`, `user_id`, `blog_post_date`, `attach_count`, `embed_metadata`, `view_count`, `blog_post_state`, `reaction_score`, `reactions`, `reaction_users`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src\XF\Db\Mysqli\Statement.php(207): XF\Db\AbstractStatement->getException('MySQL statement...', 1054, '42S22')
#1 src\XF\Db\Mysqli\Statement.php(46): XF\Db\Mysqli\Statement->getException('MySQL statement...', 1054, '42S22')
#2 src\XF\Db\Mysqli\Statement.php(61): XF\Db\Mysqli\Statement->prepare()
#3 src\XF\Db\AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#4 src\XF\Db\AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#5 src\XF\Mvc\Entity\Entity.php(1570): XF\Db\AbstractAdapter->insert('xf_taylorj_blog...', Array, false)
#6 src\XF\Mvc\Entity\Entity.php(1300): XF\Mvc\Entity\Entity->_saveToSource()
#7 src\XF\Mvc\FormAction.php(72): XF\Mvc\Entity\Entity->save(true, false)
#8 src\XF\Mvc\FormAction.php(190): XF\Mvc\FormAction->XF\Mvc\{closure}(Object(XF\Mvc\FormAction))
#9 src\addons\TaylorJ\Blogs\Pub\Controller\Blog.php(130): XF\Mvc\FormAction->run()
#10 src\addons\TaylorJ\Blogs\Pub\Controller\Blog.php(112): TaylorJ\Blogs\Pub\Controller\Blog->blogPostSaveProcess(Object(TaylorJ\Blogs\Entity\BlogPost), Object(XF\Mvc\ParameterBag))
#11 src\XF\Mvc\Dispatcher.php(362): TaylorJ\Blogs\Pub\Controller\Blog->actionPostSave(Object(XF\Mvc\ParameterBag))
#12 src\XF\Mvc\Dispatcher.php(265): XF\Mvc\Dispatcher->dispatchClass('TaylorJ\\Blogs:B...', 'PostSave', Object(XF\Mvc\RouteMatch), Object(TaylorJ\Blogs\Pub\Controller\Blog), NULL)
#13 src\XF\Mvc\Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(TaylorJ\Blogs\Pub\Controller\Blog), NULL)
#14 src\XF\Mvc\Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src\XF\App.php(2813): XF\Mvc\Dispatcher->run()
#16 src\XF.php(802): XF\App->run()
#17 index.php(23): XF::runApp('XF\\Pub\\App')
#18 {main}

array(4) {
  ["url"] => string(43) "/xenforo23/index.php?blogs/blog/0/post-save"
  ["referrer"] => string(71) "http://localhost/xenforo23/index.php?blogs/blog/blog-de-test.3/add-post"
  ["_GET"] => array(1) {
    ["blogs/blog/0/post-save"] => string(0) ""
  }
  ["_POST"] => array(9) {
    ["_xfToken"] => string(8) "********"
    ["blog_post_title"] => string(4) "test"
    ["message_html"] => string(11) "<p>test</p>"
    ["attachment_hash"] => string(32) "47372b2f38f8ce78a1513f6b589d59a7"
    ["attachment_hash_combined"] => string(108) "{"type":"taylorj_blogs_blog_post","context":{"blog_post_id":null},"hash":"47372b2f38f8ce78a1513f6b589d59a7"}"
    ["blog_id"] => string(1) "3"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["_xfRequestUri"] => string(55) "/xenforo23/index.php?blogs/blog/blog-de-test.3/add-post"
  }
}
 
Last edited by a moderator:
XF 2.3

If you try to edit a blog, the new values are not applied to the blog, it creates a new blog with the new values.
Here, i just changed the header image...

Capture d'écran 2024-08-09 075911.webp
 
And it would also be more conventional if the answer values of Created by (Author maybe?), Created on (Creation date maybe?) and Total posts were displayed aligned to the right, like resource infos. (It's a very small detail but the titles mentioned above should be dimmed in color).
Phrases are hard-coded in your template. :(
Some are already exist in XF so you can use it (but you must create the phrase for Entries/Posts), i just edit the relevant part from the taylorj_blogs_blog_view template:
HTML:
        <div class="taylorJUserBlogs-details-text">
            <dl class="pairs pairs--justified">
                <dt>{{ phrase('author') }}</dt>
                <dd>{$blog.User.username}</dd>
            </dl>
            <dl class="pairs pairs--justified">
                <dt>{{ phrase('created') }}</dt>
                <dd><xf:date time="$blog.blog_creation_date" /></dd>
            </dl>
            <dl class="pairs pairs--justified">
                <dt>Entries</dt>
                <dd>{$blogPost.Blog.blog_post_count|number}</dd>
            </dl>
        </div>

And edit the less code with XF syntax for padding
Less:
.taylorJUserBlogs-details-text {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  padding: @xf-paddingMedium @xf-paddingLarge;
  gap: 5px;
}

Capture d'écran 2024-08-09 092948.webp
 
Last edited by a moderator:
If it helps, I edited the 2 Less files of the add-on using the predefined XF variables for background, border-color, radius, text color, padding, etc. so it will automatically adapt to user customizations if applicable and most importantly this will be ready for XF 2.3 and style variations. I am attaching the files to you.

Results:

1723197152810.webp

XF 2.3

If a blog does not have a header image it displayed well in Index blog page but bad in the blog page:

1723197234792.webp

1723197260322.webp
 

Attachments

Last edited by a moderator:
Miss this one, taylorj_blogs_blog_post_view.less
Less:
.taylorJUserBlogs-post-content {
    padding: @xf-paddingLarge;
}
 
XF 2.3

Trying to create a blog entry:

View attachment 308359


Code:
XF\Db\Exception: MySQL statement prepare error [1054]: Unknown column 'view_count' in 'field list' src\XF\Db\AbstractStatement.php:230

Stack trace
INSERT  INTO `xf_taylorj_blogs_blog_post` (`blog_post_title`, `blog_id`, `blog_post_content`, `blog_post_last_edit_date`, `user_id`, `blog_post_date`, `attach_count`, `embed_metadata`, `view_count`, `blog_post_state`, `reaction_score`, `reactions`, `reaction_users`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src\XF\Db\Mysqli\Statement.php(207): XF\Db\AbstractStatement->getException('MySQL statement...', 1054, '42S22')
#1 src\XF\Db\Mysqli\Statement.php(46): XF\Db\Mysqli\Statement->getException('MySQL statement...', 1054, '42S22')
#2 src\XF\Db\Mysqli\Statement.php(61): XF\Db\Mysqli\Statement->prepare()
#3 src\XF\Db\AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#4 src\XF\Db\AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#5 src\XF\Mvc\Entity\Entity.php(1570): XF\Db\AbstractAdapter->insert('xf_taylorj_blog...', Array, false)
#6 src\XF\Mvc\Entity\Entity.php(1300): XF\Mvc\Entity\Entity->_saveToSource()
#7 src\XF\Mvc\FormAction.php(72): XF\Mvc\Entity\Entity->save(true, false)
#8 src\XF\Mvc\FormAction.php(190): XF\Mvc\FormAction->XF\Mvc\{closure}(Object(XF\Mvc\FormAction))
#9 src\addons\TaylorJ\Blogs\Pub\Controller\Blog.php(130): XF\Mvc\FormAction->run()
#10 src\addons\TaylorJ\Blogs\Pub\Controller\Blog.php(112): TaylorJ\Blogs\Pub\Controller\Blog->blogPostSaveProcess(Object(TaylorJ\Blogs\Entity\BlogPost), Object(XF\Mvc\ParameterBag))
#11 src\XF\Mvc\Dispatcher.php(362): TaylorJ\Blogs\Pub\Controller\Blog->actionPostSave(Object(XF\Mvc\ParameterBag))
#12 src\XF\Mvc\Dispatcher.php(265): XF\Mvc\Dispatcher->dispatchClass('TaylorJ\\Blogs:B...', 'PostSave', Object(XF\Mvc\RouteMatch), Object(TaylorJ\Blogs\Pub\Controller\Blog), NULL)
#13 src\XF\Mvc\Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(TaylorJ\Blogs\Pub\Controller\Blog), NULL)
#14 src\XF\Mvc\Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src\XF\App.php(2813): XF\Mvc\Dispatcher->run()
#16 src\XF.php(802): XF\App->run()
#17 index.php(23): XF::runApp('XF\\Pub\\App')
#18 {main}

array(4) {
  ["url"] => string(43) "/xenforo23/index.php?blogs/blog/0/post-save"
  ["referrer"] => string(71) "http://localhost/xenforo23/index.php?blogs/blog/blog-de-test.3/add-post"
  ["_GET"] => array(1) {
    ["blogs/blog/0/post-save"] => string(0) ""
  }
  ["_POST"] => array(9) {
    ["_xfToken"] => string(8) "********"
    ["blog_post_title"] => string(4) "test"
    ["message_html"] => string(11) "<p>test</p>"
    ["attachment_hash"] => string(32) "47372b2f38f8ce78a1513f6b589d59a7"
    ["attachment_hash_combined"] => string(108) "{"type":"taylorj_blogs_blog_post","context":{"blog_post_id":null},"hash":"47372b2f38f8ce78a1513f6b589d59a7"}"
    ["blog_id"] => string(1) "3"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["_xfRequestUri"] => string(55) "/xenforo23/index.php?blogs/blog/blog-de-test.3/add-post"
  }
}
For this one, would you mind grabbing a screenshot of your database, specifically the entirety of the xf_taylorj_blogs_blog_post table and posting it here. I was not able to reproduce this one on a fresh 2.3.2 install.
 
Back
Top Bottom