Difference between revisions of "Site:Developer stuff/Changing next and previous links"

From Feast upon the Word (http://feastupontheword.org). Copyright, Feast upon the Word.
Jump to: navigation, search
(initial content)
 
(Building blocks: fixing middle content)
Line 24: Line 24:
 
' )-instr(cur_text , '|}' )), b.*
 
' )-instr(cur_text , '|}' )), b.*
 
from test.commentary_pages_ordered a , thestandardworks.cur b   
 
from test.commentary_pages_ordered a , thestandardworks.cur b   
where a.cur_id=b.cur_id  and right(SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-153 +instr(right(cur_text , 150 ), '{|  width="20%"
+
where a.cur_id=b.cur_id  and right(SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-153 +instr(right(cur_text , 150 ), '{|  width="20%"' )-instr(cur_text , '|}' )), 4 )<>'----'  
' )-instr(cur_text , '|}' )), 4 )<>'----'  
+
</pre>
+
 
+
Update Statement
+
(This isn't working. It is cutting off the middle content. Not sure why yet. Need to troubleshoot.)
+
<pre>
+
UPDATE thestandardworks.cur b
+
INNER JOIN test.commentary_pages_ordered a
+
ON a.cur_id=b.cur_id
+
SET b.cur_text = concat('{| 
+
| [['
+
, SUBSTRING( cur_text , 21, instr( cur_text , '|Previous]]' ) - 21)
+
, '|Previous ('
+
, SUBSTRING( cur_text , 21, instr( cur_text , '|Previous]]' ) - 21)
+
, ')]]  || &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || [['
+
, SUBSTRING( cur_text, char_length(cur_text)-65+instr( right(cur_text, 70), '|| [['), 56 - instr( right(cur_text, 70), '|| [['))
+
, '|Next ('
+
, SUBSTRING( cur_text, char_length(cur_text)-65+instr( right(cur_text, 70), '|| [['), 56 - instr( right(cur_text, 70), '|| [['))
+
, ')]]
+
|}'
+
, SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-123 + instr(right(cur_text , 120 ), '{|  width="20%"
+
' )-instr(cur_text , '|}' ))
+
, '
+
{| 
+
| [['
+
, SUBSTRING( cur_text , 21, instr( cur_text , '|Previous]]' ) - 21)
+
, '|Previous ('
+
, SUBSTRING( cur_text , 21, instr( cur_text , '|Previous]]' ) - 21)
+
, ')]]  || &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || [['
+
, SUBSTRING( cur_text, char_length(cur_text)-65+instr( right(cur_text, 70), '|| [['), 56 - instr( right(cur_text, 70), '|| [['))
+
, '|Next ('
+
, SUBSTRING( cur_text, char_length(cur_text)-65+instr( right(cur_text, 70), '|| [['), 56 - instr( right(cur_text, 70), '|| [['))
+
, ')]]
+
|}')
+
WHERE b.CUR_ID=65259
+
 
</pre>
 
</pre>

Revision as of 04:14, 2 October 2006

Code isn't working yet, but I need to stop for now.

Note: this code is really ugly but it seemed easier to do this than working on something nicer.

Objective: Change "Next" and "Previous" links to show the user where they will be taken when they click them.

Building blocks

Name of previous page

SUBSTRING( cur_text , 21, instr( cur_text , '|Previous]]' ) - 21)

Name of next page

SUBSTRING( cur_text, char_length(cur_text)-65+instr( right(cur_text, 70), '|| [['), 56 - instr( right(cur_text, 70), '|| [['))

Middle content

 SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-153 +instr(right(cur_text , 150 ), '{|  width="20%" 
' )-instr(cur_text , '|}' ))


Test of middle content

select SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-153 +instr(right(cur_text , 150 ), '{|  width="20%"
' )-instr(cur_text , '|}' )), b.*
from test.commentary_pages_ordered a , thestandardworks.cur b  
where a.cur_id=b.cur_id  and right(SUBSTRING(cur_text , instr(cur_text , '|}' )+2 , char_length(cur_text )-153 +instr(right(cur_text , 150 ), '{|  width="20%"' )-instr(cur_text , '|}' )), 4 )<>'----'