PDA

View Full Version : Update Thread Title Global


I.G.O.T.A.
02-02-2018, 09:55 AM
We have a pretty big thread and the title needs to be changed for each post. Instead of doing it manually if you change the first post how do you update it globally?

Thank you,
JJ

I.G.O.T.A.
02-15-2018, 06:04 PM
Anyone?

Inna
02-16-2018, 07:52 AM
If no one else in that thread has chosen manual title (for example thread title is "how to", but my post which is the 3rd one in that thread titles "how not to", then either you should
1) do it manually
2) run a query in phpmyadmin to change all titles of posts of this specific thread

MarkFL
02-16-2018, 10:36 AM
Create a plugin hooked at "threaddata_presave" with the code:

global $vbulletin;

if ($vbulletin->GPC['threadid'] == XXX)
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET title = '" . $vbulletin->db->escape_string($vbulletin->GPC['title']) . "'
WHERE threadid = " . $vbulletin->GPC['threadid'] . "
AND parentid != 0
");
}

Replace "XXX" with the threadid of the thread you want affected.

I.G.O.T.A.
02-18-2018, 02:44 PM
Create a plugin hooked at "threaddata_presave" with the code:

global $vbulletin;

if ($vbulletin->GPC['threadid'] == XXX)
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET title = '" . $vbulletin->db->escape_string($vbulletin->GPC['title']) . "'
WHERE threadid = " . $vbulletin->GPC['threadid'] . "
AND parentid != 0
");
}

Replace "XXX" with the threadid of the thread you want affected.

Thanks!

Going to do this now.

--------------- Added 1518972702 at 1518972702 ---------------

Tried it and didn't work. Any idea what I did wrong?

MarkFL
02-18-2018, 02:54 PM
Are you sure you used the correct thread id?

Before you saved the plugin, did you make it active?

I.G.O.T.A.
02-18-2018, 02:58 PM
Are you sure you used the correct thread id?

Before you saved the plugin, did you make it active?

Yes, then I went and changed the title and it didn't update the other posts.

MarkFL
02-18-2018, 03:00 PM
Odd...it worked for me.

I.G.O.T.A.
02-18-2018, 03:01 PM
Odd...it worked for me.

It the thread ID just the number?

Is that the only thing to change?

MarkFL
02-18-2018, 03:05 PM
It the thread ID just the number?

Is that the only thing to change?

Can you post a link to the thread?

I.G.O.T.A.
02-18-2018, 03:06 PM
The link is below friend.

https://www.igotacummins.com/threads/10573-Double-R-Diesel-Customer-Trucks

MarkFL
02-18-2018, 03:08 PM
The link is below friend.

https://www.igotacummins.com/threads/10573-Double-R-Diesel-Customer-Trucks

Okay, what you should have is:

global $vbulletin;

if ($vbulletin->GPC['threadid'] == 10573)
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET title = '" . $vbulletin->db->escape_string($vbulletin->GPC['title']) . "'
WHERE threadid = " . $vbulletin->GPC['threadid'] . "
AND parentid != 0
");
}

I.G.O.T.A.
02-18-2018, 03:10 PM
I have that, but if you look at all the titles after that they don't update.

MarkFL
02-18-2018, 03:13 PM
Well, like I said that query works for me...don't know what issue there is at your site preventing it from running.

I.G.O.T.A.
02-18-2018, 03:18 PM
Well, like I said that query works for me...don't know what issue there is at your site preventing it from running.

Yes, that is very strange.

Thanks for the help. I will see if I can figure this out as I do have a PHP error.

156945

I.G.O.T.A.
02-18-2018, 03:22 PM
Just turned off all the plugins to see if it would update and nothing.

So strange...

MarkFL
02-18-2018, 03:29 PM
If you turned off all plugins (disabled hooks), then this new plugin won't run.

I.G.O.T.A.
02-18-2018, 05:50 PM
If you turned off all plugins (disabled hooks), then this new plugin won't run.

I didn't do it globally, just one at a time.

MarkFL
02-18-2018, 05:53 PM
I would first try turning off any plugins hooked at the same location.

I.G.O.T.A.
02-19-2018, 12:39 PM
I would first try turning off any plugins hooked at the same location.

I will try that.

Thank you, sir.

--------------- Added 1519051345 at 1519051345 ---------------

So just tried and it didn't work.

We are talking about the RE: Title correct?

MarkFL
02-19-2018, 01:33 PM
I'm talking about all plugins whose hook location is "threaddata_presave."

I.G.O.T.A.
02-19-2018, 02:38 PM
I'm talking about all plugins whose hook location is "threaddata_presave."

Yep, I did that.

So let me walk through this one more time.

First I create a plugin hooked at "threaddata_presave" with the code:

global $vbulletin;

if ($vbulletin->GPC['threadid'] == XXX)
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET title = '" . $vbulletin->db->escape_string($vbulletin->GPC['title']) . "'
WHERE threadid = " . $vbulletin->GPC['threadid'] . "
AND parentid != 0
");
}

Using my ID number which is 10573 in the XXX

Next, I go to the thread and update the title and hit save. The title changes, but only the main one which is my issue, not all the rest of the posts.

Is that correct sir?

MarkFL
02-19-2018, 02:43 PM
For whatever reason that plugin is not executing...have no idea why...it works perfectly for me.

I.G.O.T.A.
02-19-2018, 02:52 PM
I have an idea, brb.

--------------- Added 1519059557 at 1519059557 ---------------

GOT IT! ;)

Thank you!!!

MarkFL
02-19-2018, 03:26 PM
I have an idea, brb.

--------------- Added 1519059557 at 1519059557 ---------------

GOT IT! ;)

Thank you!!!

The post merging here is a real PITA...the only way I knew you had posted another reply was to check, as it does not show up as a new reply.

Anyway, what was causing the plugin not to execute?

I.G.O.T.A.
02-19-2018, 04:28 PM
Our server was on fast CGI and we kept hitting limits which cause errors and issues.

Once I changed us back to just regular CGI my errors went away and everything worked. ;)

Thanks, friend,
JJ

Stratis
02-20-2018, 11:51 AM
I tested this plugin in my dev site, to work I disabled the "fast CGI"

Is there a way Mark... to the second post title and so on until last post to have the word "Re" before the title
or what else we use?

Thanks

MarkFL
02-20-2018, 04:43 PM
Just change the query to this:

$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "post
SET title = 'Re: " . $vbulletin->db->escape_string($vbulletin->GPC['title']) . "'
WHERE threadid = " . $vbulletin->GPC['threadid'] . "
AND parentid != 0
");

Stratis
02-21-2018, 03:47 AM
Ok thanks Mark , some times i get an error
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; modpm_checker has a deprecated constructor...

MarkFL
02-21-2018, 04:26 AM
Ok thanks Mark , some times i get an error
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; modpm_checker has a deprecated constructor...

That has nothing to do with the query I posted...sounds like an add-on. :)

Stratis
02-21-2018, 05:34 AM
Ok, i will see, actually i tested in my dev site, thanks for another time.