Hi,
I managed to add an additional field to the comment box - name: 'city'.
Now I want to display this like:
Tim from London - 3 days ago
...
but I only managed to show this in the backend were you manage the comments in wp:
Can you point me towards the direction where to change what to archive what I'm looking for?
Is there anything you also need to know to be able to help me?
Thanks in advance!
to be more precise I want it to look like this:
and if the field has no value it should look like this
but of course this is a matter of logic in the code (change) itself.
...again thanks a lot for any help!
Any Idea from the wpdiscuz-Team itself?
Mayby you, @asti, might help me with this?
Hi @ll,
finally I will summarize what I have done to archive this. It might inspire in similar situation.
Start by adding your additional Field in your Form
You might want to change the META-KEY under Advanced Options to something more readable to use in your code.
Have a look into the Database in Table `commentmeta` to see the real META-KEY because it is case-sensitive!
meta_id | comment_id | meta_key | meta_value |
---|---|---|---|
50 | 9 | city | Dublin |
In my case, even I wrote the META-KEY in uppercase on the Form Editor, it is saved in lowercase to the database.
Now you can start coding.
Create a Child-Theme to make all your changes update proof!
Add the following folder structure to it:
wpdiscuz/
├── class.WpdiscuzWalker.php
└── layouts
├── 1
│ ├── author.html
│ ├── city.html
│ ├── header.html
│ └── style.css
Create the file city.html is simple as:
<div class="{HEADER_WRAPPER_CLASSES}"> {AUTHOR} {CITY} {DATE} {STATUS} {SHARE} <div class="wpd-space"></div> {LINK} </div>
#wpdcom .wpd-comment-header .wpd-comment-city{ } #wpdcom .wpd-comment-header .wpd-comment-city .pre{font-style: italic;}
@@ -93,6 +93,33 @@ $commentWrapperClass[] = "wpd-reply"; } + $showCity = false; + $city = isset($commentMetas["city"][0]) ? strval($commentMetas["city"][0]) : ""; + if ($city) { + $search[] = "{CITY_WRAPPER_CLASSES}"; + $search[] = "{PRE_CITY}"; + $search[] = "{CITY}"; + $replace[] = "wpd-comment-city"; + switch( get_locale() ) { + case 'de_DE': + $replace[] = "aus"; + break; + case 'fr_FR': + case 'es_ES': + $replace[] = "de"; + break; + case 'it_IT': + $replace[] = "da"; + break; + case 'pl_PL': + $replace[] = "z"; + break; + default: + $replace[] = "from"; + } + $replace[] = $city; + $showCity = true; + } + $showDate = false; if ($this->options->thread_layouts["showCommentDate"]) { @@ -429,7 +451,8 @@ $replace[] = $content . $comment->comment_content; $replace[] = "wpd-comment-left " . esc_attr($commentLeftClass); $leftComponent = $showAvatar || $showLabel || $showFollow ? str_replace(["{AVATAR}", "{LABEL}", "{FOLLOW}"], [$showAvatar ? $args["components"]["avatar.html"] : "", ($showLabel ? $args["components"]["label.html"] : "") . apply_filters("wpdiscuz_after_label", "", $comment), $showFollow ? $args["components"]["follow.html"] : ""], $args["components"]["left.html"]) : ""; - $headerComponent = str_replace(["{AUTHOR}", "{DATE}", "{STATUS}", "{SHARE}", "{LINK}"], [$args["components"]["author.html"], $showDate ? $args["components"]["date.html"] : "", $showStatus ? $args["components"]["status.html"] : "", $showShare ? $args["components"]["share.html"] : "", $showLink ? $args["components"]["link.html"] : ""], $args["components"]["header.html"]); +// $headerComponent = str_replace(["{AUTHOR}", "{DATE}", "{STATUS}", "{SHARE}", "{LINK}"], [$args["components"]["author.html"], $showDate ? $args["components"]["date.html"] : "", $showStatus ? $args["components"]["status.html"] : "", $showShare ? $args["components"]["share.html"] : "", $showLink ? $args["components"]["link.html"] : ""], $args["components"]["header.html"]); + $headerComponent = str_replace(["{AUTHOR}", "{CITY}", "{DATE}", "{STATUS}", "{SHARE}", "{LINK}"], [$args["components"]["author.html"], $showCity ? $args["components"]["city.html"] : "", $showDate ? $args["components"]["date.html"] : "", $showStatus ? $args["components"]["status.html"] : "", $showShare ? $args["components"]["share.html"] : "", $showLink ? $args["components"]["link.html"] : ""], $args["components"]["header.html"]); $footerComponent = $showVote || $showReply || $afterReplyButton || $showTools || $showToggle ? str_replace(["{VOTE}", "{REPLY}", "{TOOLS}", "{TOGGLE}"], [$showVote ? $args["components"]["vote.html"] : "", ($showReply ? $args["components"]["reply.html"] : "") . $afterReplyButton, $showTools ? $args["components"]["tools.html"] : "", $showToggle ? $args["components"]["toggle.html"] : ""], $args["components"]["footer.html"]) : ""; $rightComponent = str_replace(["{HEADER}", "{REPLY_TO}", "{TEXT}", "{FOOTER}"], [$headerComponent, $showReplyTo ? $args["components"]["reply_to.html"] : "", $args["components"]["text.html"] . $lastEdited, $footerComponent], $args["components"]["right.html"]); $wrapperComponent = str_replace(["{LEFT}", "{RIGHT}"], [$leftComponent, $rightComponent], $args["components"]["wrapper.html"]);