Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #31  
Old December 29th, 2005, 12:55 PM
BlackSkad BlackSkad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 BlackSkad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

When having a function like this:
php Code:
Original - php Code
  1. replace_block_tags (array(key=>value))

you will have only one row in that block, which is rather useless, isn't it?
Making another function with a multi-dimensional array in case of a query isn't too difficult. Just use a for-loop to loop trough the firt part of the array ($list[$i]) in case of the while-loop with (mysql_fetch_array($query));
Calling it would then be like:
php Code:
Original - php Code
  1. replace_block_tags(array(
  2.     1 => array (
  3.        key => value
  4.     )
  5.     2 => array (
  6.        key => value
  7.     )
  8. ));

If I had the time, I would write it for you, but I haven't...

Greatz,
BlackSkad

Reply With Quote
  #32  
Old December 29th, 2005, 08:57 PM
BassFace BassFace is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Denver, Colorado USA
Posts: 9 BassFace User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

EDIT Looks like Blackskad and I posted at the same time...
Anonymous,
I guess I don't understand what you mean... The purpose of the replace_block_tags() method is to display repeating areas of dynamic generated results - namely results from a MySQL database query. With a static array, you can just use the replace_tags() method for that. Or is this a repeating array from a different source than a database? If that's the case, you could add a new method replace_array_tags() or something, using the replace_block_tags() method as a guide and just replace the db stuff with php array functions.

Reply With Quote
  #33  
Old December 31st, 2005, 12:32 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: help : looping for template

I could never get the replace block tags to work....

What array functions would I have to use to replace the mysql data?

Reply With Quote
  #34  
Old January 1st, 2006, 07:53 PM
BassFace BassFace is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Denver, Colorado USA
Posts: 9 BassFace User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

We'd really need to know more about what you want to accomplish to help you build a new method for this class. It sounds like you have a specific goal/situation you'd like to address. But like has been said above, if you are just using one static array, you should not need to use the replace_block_tags, you can just use the replace_tags method.

Show us some code or explain in detail what you would like this class to do. Who knows, there may be others out there who'd like to do the same thing... :-]


Reply With Quote
  #35  
Old January 2nd, 2006, 12:33 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: help : looping for template

Well I am trying to get it similar to what phpbb has for the assign_block_vars function. It displays the data in the array in a block. That is handy if you want to hide something or not. Also you can add it to a for statement and then have it repeat the data also.

I hope this helps. I can go into more detail if need be.

Reply With Quote
  #36  
Old January 12th, 2006, 07:31 AM
PlaGuE PlaGuE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Edmonton Alberta Canada
Posts: 16 PlaGuE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to PlaGuE
RE: help : looping for template

yeah that would be nice...

Having sumtin like phpbb's assign_block_vars

where
php Code:
Original - php Code
  1.  
  2. assign_block_vars('blockname',
  3. array('ID', $row['id'],
  4.       'USER', $row['username']
  5. ));
  6.  

so you'd call it like so...
php Code:
Original - php Code
  1.  
  2. <!-- START blockname -->
  3. {blockname.ID}
  4. <!-- END blockname -->


I got it to work awhile ago with looping.. then comp crashed and i didnt save my work..

now i gotta do it all over again..meh

Reply With Quote
  #37  
Old January 12th, 2006, 07:56 AM
PlaGuE PlaGuE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Edmonton Alberta Canada
Posts: 16 PlaGuE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to PlaGuE
RE: help : looping for template

Now although i got it to work...with looping...
the last idea would be sweet.

Reply With Quote
  #38  
Old January 14th, 2006, 01:23 PM
BlackSkad BlackSkad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 BlackSkad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

Normally, it would just be as easy as this:
php Code:
Original - php Code
  1.  
  2. function assign_block_vars ($blockname, $data)
  3. {
  4.     $blockCode = $this->block ($blockname);
  5.     foreach ($data as $key => $value) {
  6.         str_replace ("{".$blockname.".".$value."}", $value, $blockCode);
  7.     }
  8.     str_replace ($this->return[0], $blockCode.$this->return[0], $this->page);
  9. }


I haven''t test it though (no time), so it is possible there still something wrong. Note that there is a crucial difference in the last line, compared with the one below (check the second argument).
php Code:
Original - php Code
  1. str_replace ($this->return[0], $this->return[0].$blockCode, $this->page);

The function is designed to be used multiple times. So every time you use it, you replace the original code by "the replaced code" concatenated with the original part. So after 1 times calling, the block mentioned in the previous post would look like this:
php Code:
Original - php Code
  1. uid = 1
  2. username = BlackSkad
  3. <!-- START blockname -->
  4. uid = {blockname.ID}
  5. username = {blockname.USER}
  6. <!-- END blockname -->


If you replace the last line in the function with the one I mentioned in the note, you''ll get something like below. Your items are printed on screen in the reverse order. The one you replaced first, will at the bottom of the page.
php Code:
Original - php Code
  1. <!-- START blockname -->
  2. uid = {blockname.ID}
  3. username = {blockname.USER}
  4. <!-- END blockname -->
  5. uid = 1
  6. username = BlackSkad


Your choice which way you like best...

Reply With Quote
  #39  
Old January 28th, 2006, 06:09 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: help : looping for template

I can't get it to work. I have tried everything you posted.

Reply With Quote
  #40  
Old January 29th, 2006, 10:30 AM
BlackSkad BlackSkad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 BlackSkad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

Does it gives any error? would be usefull to help...

Reply With Quote
  #41  
Old February 16th, 2006, 05:39 PM
PlaGuE PlaGuE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Edmonton Alberta Canada
Posts: 16 PlaGuE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to PlaGuE
RE: help : looping for template

niice.

I dont really get an error... exept for it using block not get_block... but all its doing is
php Code:
Original - php Code
  1.  
  2. <div>
  3. UserName: {blockname.user}
  4. </div>
instead of
php Code:
Original - php Code
  1.  
  2. <div>
  3. UserName: plaGuE
  4. </div>

Reply With Quote
  #42  
Old February 22nd, 2006, 10:02 PM
BlackSkad BlackSkad is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 BlackSkad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: help : looping for template

Did you replace the word 'blockname' in the tag with the real name of the blog? So you have something like
php Code:
Original - php Code
  1. <!-- START myblock -->
  2. username = {myblock.USER}
  3. <!-- END myblock -->


That almost seems like the only possibility for a mistake, because the functions works fine on my testing-server...