The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Type of Site:

View previous topic View next topic Go down

In progress Type of Site:

Post by Mati on October 2nd 2015, 6:01 pm

I want a select script code to show above the "Title of the topic" when members open a new topic they choose what type of sites they have just for one section Request Center. -> http://forumdirectory.forumotion.net/f16-request-center

Is your site a website, blog, or forum? with 3 option

Website
Blog
Forum




Mati
Active Poster

Posts : 1873
Reputation : 281
Language : || HTML || CSS || jQuery ||
Location : At the Gym

http://elite-gaming.forumotion.net/

Back to top Go down

In progress Re: Type of Site:

Post by Mati on October 4th 2015, 12:02 pm

Anyone knows...

Mati
Active Poster

Posts : 1873
Reputation : 281
Language : || HTML || CSS || jQuery ||
Location : At the Gym

http://elite-gaming.forumotion.net/

Back to top Go down

In progress Re: Type of Site:

Post by Ange Tuteur on October 4th 2015, 4:08 pm

Hi @Mati,

Just to clarify ; You want a selection drop down before the topic title input field, and when you select an option it'll add it to the beginning of the topic title, correct ?

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Type of Site:

Post by Mati on October 4th 2015, 7:14 pm

That's correct. thumleft

Mati
Active Poster

Posts : 1873
Reputation : 281
Language : || HTML || CSS || jQuery ||
Location : At the Gym

http://elite-gaming.forumotion.net/

Back to top Go down

In progress Re: Type of Site:

Post by Ange Tuteur on October 5th 2015, 11:20 am

Try the following. Smile

Go to Modules > JavaScript codes management > Create a new script

Placement : In all the pages
Code:
$(function() {
  var config = {
    name : '<strong>Select your website type :</strong> ',
    option : {
      'Is your site a website, blog, or forum?' : 'DEFAULT',
      'Website' : 'Website',
      'Blog' : 'Blog',
      'Forum' : 'Forum'
    }
  },
  bloc, select, i;

  if (document.post && document.post.f && document.post.f.value == 16) {
    select = document.createElement('SELECT');
    bloc = document.createElement('DL');

    for (i in config.option) select.innerHTML += '<option value="' + config.option[i] + '">' + i + '</option>';
   
    select.onchange = function() {
      var sujet = document.post.subject;
     
      if (this.value == 'DEFAULT') sujet.value = sujet.value.replace(/^\[.*?\]\s/, '');
      else {
        if (/^\[.*?\]\s/.test(sujet.value)) sujet.value = sujet.value.replace(/^\[.*?\]\s/, '');
        sujet.value = '[' + this.value + '] ' + sujet.value;
      }
    };


    bloc.innerHTML = '<dt><label>' + config.name + '</label></dt><dd></dd>';
    bloc.getElementsByTagName('DD')[0].appendChild(select);

    document.post.subject.parentNode.parentNode.parentNode.insertBefore(bloc, document.post.subject.parentNode.parentNode);
  }
});

At the top you can change the label, and option names : values.

If any questions let me know. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Type of Site:

Post by Mati on October 5th 2015, 4:36 pm

Works perfect how I wanna it xD but is it possible to add classes for each of them

Code:
<div class="text_forum">Forum</div>
<div class="text_blog">Blog</div>
<div class="text_web">Website</div>

So I can style it with CSS.

Mati
Active Poster

Posts : 1873
Reputation : 281
Language : || HTML || CSS || jQuery ||
Location : At the Gym

http://elite-gaming.forumotion.net/

Back to top Go down

In progress Re: Type of Site:

Post by Ange Tuteur on October 5th 2015, 6:09 pm

Replace the script with this :
Code:
$(function() {
  var config = {
    name : '<strong>Select your website type :</strong> ',
    option : {
      'Is your site a website, blog, or forum?' : ['DEFAULT', 'text_default'],
      'Website' : ['Website', 'text_web'],
      'Blog' : ['Blog', 'text_blog'],
      'Forum' : ['Forum', 'text_forum']
    }
  },
  bloc, select, i;

  if (document.post && document.post.f && document.post.f.value == 16) {
    select = document.createElement('SELECT');
    bloc = document.createElement('DL');

    for (i in config.option) select.innerHTML += '<option value="' + config.option[i][0] + '" '+ (config.option[i][1] ? 'class="' + config.option[i][1] + '"' : '') +'>' + i + '</option>';
   
    select.onchange = function() {
      var sujet = document.post.subject;
     
      if (this.value == 'DEFAULT') sujet.value = sujet.value.replace(/^\[.*?\]\s/, '');
      else {
        if (/^\[.*?\]\s/.test(sujet.value)) sujet.value = sujet.value.replace(/^\[.*?\]\s/, '');
        sujet.value = '[' + this.value + '] ' + sujet.value;
      }
    };


    bloc.innerHTML = '<dt><label>' + config.name + '</label></dt><dd></dd>';
    bloc.getElementsByTagName('DD')[0].appendChild(select);

    document.post.subject.parentNode.parentNode.parentNode.insertBefore(bloc, document.post.subject.parentNode.parentNode);
  }
});

I changed the value into an array :
['VALUE', 'CLASSNAME']

class name is optional of course. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Type of Site:

Post by Mati on October 5th 2015, 6:35 pm

Ain't working I have made a topic as you can see http://forumdirectory.forumotion.net/f16-request-center there is no class?

Mati
Active Poster

Posts : 1873
Reputation : 281
Language : || HTML || CSS || jQuery ||
Location : At the Gym

http://elite-gaming.forumotion.net/

Back to top Go down

In progress Re: Type of Site:

Post by Ange Tuteur on October 5th 2015, 7:35 pm

Oh, you mean style the texts in the title ? You'd need to set a JavaScript in the sub-forums. Use this :
Code:
$(function() {
  var keywords = {
    '[Forum]' : 'tag-forum',
    '[Blog]' : 'tag-blog',
    '[Website]' : 'tag-website'
  },
  title = $('a.topictitle'), i = 0, j = title.length, k, str, reg;

  for (; i < j; i++) {
    str = title[i].innerHTML;
    for (k in keywords) {
      reg = new RegExp('^' + k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), 'i');
      if (reg.test(str)) {
        title[i].innerHTML = str.replace(reg, '<span class="' + keywords[k] + '">' + k.replace(/\[|\]/g, '') + '</span>');
        break;
      }
    }
  }
});

At the top is an object which contains the tag name + the class you want applied to it. Then you just need to use CSS to style the texts.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

In progress Re: Type of Site:

Post by brandon_g on October 11th 2015, 3:53 pm

Is this solved @Mati or still on going?

-Brandon


Remember to mark your topic when a solution is found.

brandon_g
Support Moderator
Support Moderator

Male Posts : 5139
Reputation : 478
Language : English
Location : USA

http://broadcastingduo.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum