Recent Topics

1 Oct 08, 2018 11:41    

Hello,
Am creating my post section in forum to allow logged in user access post created by them. Using widget , am adding menu , link type selected "Any URL", in URL sending[ base_ur]l/?disp=useritems&user_ID=??.

  1. Here how do set logged in user id.
    2 . Also i selected "Hightlight current" but it is not highlighting the selected menu
    3 .And how do i restrict this menu only for logged in user.
    Please help

Thanks
Kalavathi

2 Oct 08, 2018 21:23

Am creating my post section in forum to allow logged in user access post created by them. Using widget , am adding menu , link type selected "Any URL", in URL sending[ base_ur]l/?disp=useritems&user_ID=??.

Not sure what you mean but user permissions control precisely which post can be viewed, does this not work in the forum skin?

3 Oct 09, 2018 04:52

i think you have not understood my question correctly. am trying to upload image which support my question but it upload is failed . Do we have any criteria to upload image?
Let me put in simple way consider am a forum user i have created few topics my agenda is to provide menu say "My post" when user clicks that list out the topics created by them.

4 Oct 09, 2018 11:24

OK think I've got it. Will respond soon :)

Hope this helps

As for failure to upload images you would have to give lots more detail. If you still have problems instigate a new post starting with your version number

6 Oct 09, 2018 11:48

https://b2evolution.net/?disp=useritems&user_ID=??? for this request disp and user_ID are input parameters for user_ID we need to pass logged in user id that is challenge here.
Please look into below steps you may get clear understanding of my question
login to back office
forums->widgets->menu->add widget->Menu Item Widgets->Menu link
you will get form : in param block
Link Type: ->Any url
URL : https://b2evolution.net/?disp=useritems&user_ID=??? (THIS WILL BE THE INPUT FOR URL FIELD)
My question here how do i pass logged in user id in this set up.
Attached screenshot for your reference

Thanks

7 Oct 09, 2018 15:37

Working on it :) for hours :(

8 Oct 09, 2018 22:08

@kalavathi We are going to make a change to allow to call ?disp=useritems without a user_ID param and in that case it will display the posts of the current user.

9 Oct 09, 2018 22:33

Hi @fplanque

Is it not possible to pass a parameter value to [&user_ID=] other than a number?

10 Oct 09, 2018 23:06

Yes but it's harder and creates a less clean URL.

11 Oct 10, 2018 00:10

Still would be nice to know how to do it :) Given the hours I've tried :(

12 Oct 10, 2018 05:04

@fplanque if ?disp=useritems works without user_ID it will be helpful ,but will that applicable for version which we are using?

13 Oct 10, 2018 12:37

I am not sure of what you mean. Please make an effort to write in proper English.

You will have to upgrade to b2evo 6.10.4 or 6.10.5... (not sure yet in which version the new feature will be available)..

14 Oct 10, 2018 13:37

Ok

In [/my_skin/_body_header_inc.php] I added

<script>
var uid = "<?php echo $current_User->ID; ?>";
</script>

Then added a new FreeHTML widget with this
<script>
url="http://calstock.org.uk/?disp=useritems&user_ID=" + uid;
document.write("<a href=" + url + ">My Posts :: <em>All collections</em></a>");
</script>

15 Oct 10, 2018 14:30

Note to previous post #14 and it's edit :: amended the link text

The script brings up all posts by the current logged in user irrespective of the collection and have amended the link text to reflect that.

Moved the script to a pre existing FreeHTML widget to avoid a new widget heading, rather than use empty content for Block Title etc.

16 Oct 10, 2018 15:07

A bit curious as am able to edit previous posts but not add an image.
Anyway as a follow up to #15 this is an image of the link shown if logged in else it's not there as in http://calstock.org.uk/elf.php

17 Oct 25, 2018 13:18

@amoun i tried solution mentioned in #14, it does not work. it will not show any tab. In addition to that i tried

<li class="evo_widget widget_core_menu_link"><a href="/index.php/forums/?disp=useritems&amp;user_ID=<?php echo $current_User->ID;?>" class="default">My posts</a></li>

Here i am not understanding why it is not accepting PHP tag, because in url it is not giving user id instead it showing the PHP tag as it is. The above code snippet i written in "block content "field in free html widget.

One thing i observed from all these tries is back office customization's not accepting the PHP tags.

18 Oct 25, 2018 14:52

@kalavathi wrote earlier:

@amoun i tried solution mentioned in #14, it does not work. it will not show any tab. In addition to that i tried


&lt;li class=&quot;evo_widget widget_core_menu_link&quot;&gt;&lt;a href=&quot;/index.php/forums/?disp=useritems&amp;amp;user_ID=&lt;?php echo $current_User-&gt;ID;?&gt;&quot; class=&quot;default&quot;&gt;My posts&lt;/a&gt;&lt;/li&gt;


Here i am not understanding why it is not accepting PHP tag, because in url it is not giving user id instead it showing the PHP tag as it is. The above code snippet i written in &quot;block content &quot;field in free html widget.


One thing i observed from all these tries is back office customization's not accepting the PHP tags.

If you read my posts differently/more carefully :) you will see you cannot add php to widgets.

  1. As in the first part of #14 you will need to convert the php variable to a javascript variable then
  2. use the javascript variable in a widget and
  3. note in #15 the use of a new widget

19 Oct 26, 2018 07:41

whatever code written inside script tag is not appearing in front office for example
<script>
url="http://calstock.org.uk/?disp=useritems&user_ID=" + uid;
document.write("<li class="evo_widget widget_core_menu_link"><a href="/index.php/forums/?disp=useritems&amp;user_ID=" class="default">My posts</a></li>");
</script> it will not show any tab in the front office.

At the same time following code will show the tab in front office but in url am not able to send current user id
<li class="evo_widget widget_core_menu_link"><a href="/index.php/forums/?disp=useritems&amp;user_ID=<?php echo $current_user->ID;?>" class="default">My posts</a></li>

20 Oct 26, 2018 11:00

@kalavathi wrote earlier:

whatever code written inside script tag is not appearing in front office

I think you will have to explain to me from the beginning.

1) Where did you put the code to convert the php variable?
You must convert the php variable to a javascript one
<script>
var uid = "<?php echo $current_User->ID; ?>";
</script>

2) Where are you putting the code
<script>
url="http://calstock.org.uk/?disp=useritems&user_ID=" + uid;
document.write("<a href=" + url + ">My Posts :: <em>All collections</em></a>");
</script>
and why have you
a) used my domain
b) used a list tag to encompass it
c) In this case you will have an undefined variable so the script won't work

3)
a) You cannot put php in a widget as that would present a security issue. You must use javascript only in the widget so
<li class="evo_widget widget_core_menu_link"><a href="/index.php/forums/?disp=useritems&amp;user_ID=<?php echo $current_user->ID;?>" class="default">My posts</a></li> is no good
b) The link may show but the code won't work as the php part is unacceptable

If you still have problems I think you'd be better off showing screen shots of what you are doing

21 Oct 26, 2018 12:01

As a note This will only work for a logged in member as there is no used Id otherwise, which is also why the link will not show when you use php in the widget, as the ID cannot be accessed so it is the same as not being logged in.

22 Oct 26, 2018 12:09

In my localhost and b2evolution demo site i have tried writing script without any variables and php tags , still the html inside script doesn't appear in front office . for example
<script>
document.write("<a href="# ">My Posts :: <em>All collections</em></a>");
</script>
the above code i placed in free html widget -> block content field, as you suggested in #14

In replies to #21, yes am implementing this for logged in users only.

23 Oct 27, 2018 11:52

Hi @kalavathi
1) Did you add a widget title and did you get that to show.
2) In your script you can not have double quotes inside double quotes as you have shown change code to

<script>
document.write("<a href='#'>My Posts :: <em>All collections</em></a>");
</script>

The way you have it the document.write ends at the double quote before the hash character.

3) Have you allowed html tags in posts under settings >item types > posts

24 Oct 30, 2018 03:37

HI @amoun
i tried #14 ,
<script>
var uid = "<?php echo $current_User->ID; ?>";
</script>
this i added in header file, if i check in page source uid is refelecting but uid is not appearing in script added in widget
<script>
url="http://calstock.org.uk/?disp=useritems&user_ID=" + uid;
document.write("<a href=" + url + ">My Posts :: <em>All collections</em></a>");
</script>

25 Oct 30, 2018 12:59

I am surprised that you have not got this working after so long

1) You have failed to acknowledge parts 3) in comment #23
2) So you have the javascript var uid showing in the source? please show me a screen shot of this so I can see what you are actually doing and where you see it.
3) The uid will not show in the 'script added to the widget' it will only show once the widget is run if javascript is enabled as in parts 3) in comment #23, all other things correct.
4) Please show a screen shot of the widget content form?

You are not clear enough about what you are doing.

As well as all of the above

5) Do you get any text from your widget
There follows two images
a) the widget content
b) the output in my sidebar


Form is loading...